Skip to content

Commit

Permalink
Dependency Update (#167)
Browse files Browse the repository at this point in the history
While updating some dependencies we learned that testnet archival nodes
don't keep old transaction data around. So we also had to update some
test hashes.
  • Loading branch information
bh2smith authored Feb 25, 2025
1 parent d6b603a commit 01b8f41
Show file tree
Hide file tree
Showing 5 changed files with 357 additions and 726 deletions.
3 changes: 1 addition & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,15 +37,14 @@
},
"dependencies": {
"@reown/walletkit": "^1.2.0",
"@walletconnect/web3wallet": "^1.13.0",
"elliptic": "^6.5.6",
"near-api-js": "^5.0.1",
"viem": "^2.22.15"
},
"devDependencies": {
"@types/elliptic": "^6.4.18",
"@types/jest": "^29.5.12",
"@types/node": "^22.10.10",
"@types/node": "^22.13.5",
"@typescript-eslint/eslint-plugin": "^8.21.0",
"@typescript-eslint/parser": "^8.21.0",
"dotenv": "^16.4.5",
Expand Down
10 changes: 9 additions & 1 deletion src/utils/signature.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,18 @@ export async function signatureFromTxHash(
}

const json: JSONRPCResponse<FinalExecutionOutcome> = await response.json();

if (json.error) {
throw new Error(`JSON-RPC error: ${json.error.message}`);
}
if (
typeof json.result?.status === "object" &&
"Failure" in json.result.status
) {
const message = JSON.stringify(json.result.status.Failure);
throw new Error(
`Signature Request Failed in ${txHash} with message: ${message}`
);
}

if (json.result) {
return signatureFromOutcome(json.result);
Expand Down
8 changes: 4 additions & 4 deletions tests/unit/mpcContract.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,21 +8,21 @@ const path = "derivationPath";
describe("mpcContract", () => {
it("Contract (Read) Methods", async () => {
const accountId = "farmface.testnet";
const contractId = "v1.signer-dev.testnet";
const contractId = "v1.signer-prod.testnet";
const account = await createNearAccount(accountId, TESTNET_CONFIG);
const mpc = new MpcContract(account, contractId);
const ethAddress = await mpc.deriveEthAddress(path);
expect(mpc.accountId()).toEqual(contractId);
expect(ethAddress).toEqual("0xde886d5d90cf3ca465bcaf410fe2b460ec79a7d9");
expect(ethAddress).toEqual("0xaca49dcd616e2c1dce4e3490b49474af271790b5");

const signArgs = {
payload: [1, 2],
path,
key_version: 0,
};
const expected = {
signerId: "farmface.testnet",
receiverId: "v1.signer-dev.testnet",
signerId: accountId,
receiverId: contractId,
actions: [
{
type: "FunctionCall",
Expand Down
30 changes: 17 additions & 13 deletions tests/unit/utils/signature.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,27 +6,31 @@ import {

describe("utility: get Signature", () => {
const url: string = "https://archival-rpc.testnet.near.org";
// const accountId = "neareth-dev.testnet";
const successHash = "GeqmwWmWxddzh2yCEhugbJkhzsJMhCuFyQZa61w5dk7N";
const relayedSuccessHash = "G1f1HVUxDBWXAEimgNWobQ9yCx1EgA2tzYHJBFUfo3dj";
const failedHash = "6yRm5FjHn9raRYPoHH6wimizhT53PnPnuvkpecyQDqLY";
const accountId = "neareth-dev.testnet";
const successHash = "CYGDarJXUtUug83ur6QsRzr86bDjAxN3wk8N3acGXMgg";
const relayedSuccessHash = "FWtVVNGLkdAmHwQQCHvZCbNGynEWSJbeKA5GCZy1ghYf";
const failedHash = "ERdVFTNmuf1uHsiGyTu2n6XDbVfXqZXQ4N9rU6BqRMjk";
const nonExistantTxHash = "7yRm5FjHn9raRYPoHH6wimizhT53PnPnuvkpecyQDqLY";
const nonSignatureRequestHash =
"4pNDN238dgEjj5eNaAF4qzoztF4TmrN82hwJs2zTwuqe";
"BCxYwZ6YfscaHza5MEDmk4DRgKZWJ77ZtBS5L9kH3Ve7";

it("successful: signatureFromTxHash", async () => {
const sig = await signatureFromTxHash(url, successHash);
const sig = await signatureFromTxHash(url, successHash, accountId);
expect(sig).toEqual({
r: "0x3BA6A8CE1369484EF384084EC1089581D815260FC274FEF780478C7969F3CFFC",
s: "0x5194CCE1D9F239C28C7765453873A07F35850A485DFE285551FB62C899B61170",
yParity: 1,
r: "0x200209319EBF0858BB8543A9A927BDE6A54E7BD4914B76F96BDF67AEA4211CDD",
s: "0x412F478B129A7A586B158BA178C7A921978473384130ACF9E4034E16063FF5B5",
yParity: 0,
});

const relayedSig = await signatureFromTxHash(url, relayedSuccessHash);
const relayedSig = await signatureFromTxHash(
url,
relayedSuccessHash,
"mintbase.testnet"
);
expect(relayedSig).toEqual({
r: "0x593873A56AB98F91C60C23DCA370835CA05254A0305F2753A1CFC3CEB4C46F86",
s: "0x783D9887FB4AA9B07E672D7FA88587FB45E7FDC066F7ECA0774E6FE36806404F",
yParity: 1,
r: "0xFEA01D93DFF2EAA73F81545902788603E8D930786B809DC9DC62E5680D91DD72",
s: "0x4A4487EA25EDFEBBEE1FBA556AE4F90E141CAAFA13648CA8C8D144890F8EA1C4",
yParity: 0,
});
});

Expand Down
Loading

0 comments on commit 01b8f41

Please sign in to comment.