Skip to content

Commit

Permalink
Merge pull request #1029 from lostpebble/meteor/update-lib
Browse files Browse the repository at this point in the history
fix: Update Meteor Wallet SDK
  • Loading branch information
kujtimprenkuSQA authored Dec 6, 2023
2 parents 5726862 + 4d8d626 commit c6ac827
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 60 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@
"@ledgerhq/hw-transport": "6.27.1",
"@ledgerhq/hw-transport-webhid": "6.27.1",
"@metamask/detect-provider": "^2.0.0",
"@meteorwallet/sdk": "^0.8.0",
"@meteorwallet/sdk": "^1.0.5",
"@mintbase-js/wallet": "0.5.0-beta.6",
"@near-snap/sdk": "^0.6.0",
"@peersyst/near-mobile-signer": "^1.0.10",
Expand Down
46 changes: 2 additions & 44 deletions packages/meteor-wallet/src/lib/meteor-wallet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@ import type {
Account,
InjectedWallet,
Network,
Optional,
Transaction,
WalletBehaviourFactory,
WalletModuleFactory,
} from "@near-wallet-selector/core";
Expand All @@ -16,7 +14,6 @@ import {
EMeteorWalletSignInType,
MeteorWallet as MeteorWalletSdk,
} from "@meteorwallet/sdk";
import { createAction } from "@near-wallet-selector/wallet-utils";
import icon from "./icon";

const setupWalletState = async (
Expand Down Expand Up @@ -68,45 +65,6 @@ const createMeteorWalletInjected: WalletBehaviourFactory<
];
};

const transformTransactions = async (
transactions: Array<Optional<Transaction, "signerId">>
) => {
const account = _state.wallet.account()!;
const { networkId, signer, provider } = account.connection;

const localKey = await signer.getPublicKey(account.accountId, networkId);

return Promise.all(
transactions.map(async (transaction, index) => {
const actions = transaction.actions.map((action) =>
createAction(action)
);
const accessKey = await account.accessKeyForTransaction(
transaction.receiverId,
actions,
localKey
);

if (!accessKey) {
throw new Error(
`Failed to find matching key for transaction sent to ${transaction.receiverId}`
);
}

const block = await provider.block({ finality: "final" });

return nearAPI.transactions.createTransaction(
account.accountId,
nearAPI.utils.PublicKey.from(accessKey.public_key),
transaction.receiverId,
accessKey.access_key.nonce + index + 1,
actions,
nearAPI.utils.serialize.base_decode(block.header.hash)
);
})
);
};

return {
async signIn({ contractId, methodNames = [] }) {
logger.log("MeteorWallet:signIn", {
Expand Down Expand Up @@ -205,7 +163,7 @@ const createMeteorWalletInjected: WalletBehaviourFactory<

return account["signAndSendTransaction_direct"]({
receiverId: receiverId ?? contract!.contractId,
actions: actions.map((action) => createAction(action)),
actions,
});
},

Expand All @@ -219,7 +177,7 @@ const createMeteorWalletInjected: WalletBehaviourFactory<
}

return _state.wallet.requestSignTransactions({
transactions: await transformTransactions(transactions),
transactions,
});
},

Expand Down
31 changes: 16 additions & 15 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3455,13 +3455,14 @@
resolved "https://registry.yarnpkg.com/@metamask/detect-provider/-/detect-provider-2.0.0.tgz#4bc2795e5e6f7d8b84b2e845058d2f222c99917d"
integrity sha512-sFpN+TX13E9fdBDh9lvQeZdJn4qYoRb/6QF2oZZK/Pn559IhCFacPMU1rMuqyXoFQF3JSJfii2l98B87QDPeCQ==

"@meteorwallet/sdk@^0.8.0":
version "0.8.0"
resolved "https://registry.yarnpkg.com/@meteorwallet/sdk/-/sdk-0.8.0.tgz#913732c1c5210a05e008a3aedc664b16c728f682"
integrity sha512-C0x9/20t+lCMUlKSPSAbPUWjz8Ls59NwWnz/qSJM5B4qCXN3OSCcrqmpbJpSVa2wCHFhK/HuOqaKlMCr0XsQ0w==
"@meteorwallet/sdk@^1.0.5":
version "1.0.5"
resolved "https://registry.yarnpkg.com/@meteorwallet/sdk/-/sdk-1.0.5.tgz#1a878bc1357b8818cc3240a44709a6fe9971c3e1"
integrity sha512-2HT3F6O8lMvj1STD/ir09R43jPLlRVFPoR8dD+qsASUe73ZJumX8r3Uef4g9waAjKZza5B7wmi4XpamFaKrlkg==
dependencies:
nanoid "3.3.4"
query-string "^7.1.1"
borsh "^0.7.0"
nanoid "3.3.6"
query-string "^7.1.3"

"@mintbase-js/[email protected]":
version "0.5.0-beta.6"
Expand Down Expand Up @@ -16056,20 +16057,20 @@ [email protected], mute-stream@~0.0.4:
resolved "https://registry.yarnpkg.com/mute-stream/-/mute-stream-0.0.8.tgz#1630c42b2251ff81e2a283de96a5497ea92e5e0d"
integrity sha512-nnbWWOkoWyUsTjKrhgD0dcz22mdkSnpYqbEjIm2nhwhuxlSkpywJmBo8h0ZqJdkp73mb90SssHkN4rsRaBAfAA==

[email protected].4, nanoid@^3.3.4:
version "3.3.4"
resolved "https://registry.yarnpkg.com/nanoid/-/nanoid-3.3.4.tgz#730b67e3cd09e2deacf03c027c81c9d9dbc5e8ab"
integrity sha512-MqBkQh/OHTS2egovRtLk45wEyNXwF+cokD+1YPf9u5VfJiRdAiRwB2froX5Co9Rh20xs4siNPm8naNotSD6RBw==
[email protected].6, nanoid@^3.3.6:
version "3.3.6"
resolved "https://registry.yarnpkg.com/nanoid/-/nanoid-3.3.6.tgz#443380c856d6e9f9824267d960b4236ad583ea4c"
integrity sha512-BGcqMMJuToF7i1rt+2PWSNVnWIkGCU78jBG3RxO/bZlnZPK2Cmi2QaffxGO/2RvWi9sL+FAiRiXMgsyxQ1DIDA==

nanoid@^3.1.20:
version "3.3.7"
resolved "https://registry.yarnpkg.com/nanoid/-/nanoid-3.3.7.tgz#d0c301a691bc8d54efa0a2226ccf3fe2fd656bd8"
integrity sha512-eSRppjcPIatRIMC1U6UngP8XFcz8MQWGQdt1MTBQ7NaAmvXDfvNxbvWV3x2y6CdEUciCSsDHDQZbhYaB8QEo2g==

nanoid@^3.3.6:
version "3.3.6"
resolved "https://registry.yarnpkg.com/nanoid/-/nanoid-3.3.6.tgz#443380c856d6e9f9824267d960b4236ad583ea4c"
integrity sha512-BGcqMMJuToF7i1rt+2PWSNVnWIkGCU78jBG3RxO/bZlnZPK2Cmi2QaffxGO/2RvWi9sL+FAiRiXMgsyxQ1DIDA==
nanoid@^3.3.4:
version "3.3.4"
resolved "https://registry.yarnpkg.com/nanoid/-/nanoid-3.3.4.tgz#730b67e3cd09e2deacf03c027c81c9d9dbc5e8ab"
integrity sha512-MqBkQh/OHTS2egovRtLk45wEyNXwF+cokD+1YPf9u5VfJiRdAiRwB2froX5Co9Rh20xs4siNPm8naNotSD6RBw==

nanoid@^4.0.0:
version "4.0.2"
Expand Down Expand Up @@ -18308,7 +18309,7 @@ qs@~6.10.3:
dependencies:
side-channel "^1.0.4"

[email protected], query-string@^7.1.1:
[email protected], query-string@^7.1.3:
version "7.1.3"
resolved "https://registry.yarnpkg.com/query-string/-/query-string-7.1.3.tgz#a1cf90e994abb113a325804a972d98276fe02328"
integrity sha512-hh2WYhq4fi8+b+/2Kg9CEge4fDPvHS534aOOvOZeQ3+Vf2mCFsaFBYj0i+iXcAq6I9Vzp5fjMFBlONvayDC1qg==
Expand Down

0 comments on commit c6ac827

Please sign in to comment.