Skip to content

Commit 5e05db2

Browse files
committed
feat: use signature context when signing
1 parent b60e7c5 commit 5e05db2

9 files changed

Lines changed: 122 additions & 75 deletions

File tree

package.json

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "everscale-standalone-client",
3-
"version": "2.4.0",
3+
"version": "3.0.0",
44
"repository": "https://github.com/broxus/everscale-standalone-client",
55
"scripts": {
66
"prebuild": "rm -rf dist",
@@ -14,21 +14,21 @@
1414
"devDependencies": {
1515
"@types/events": "^3.0.3",
1616
"@types/node": "^22.15.29",
17-
"@typescript-eslint/eslint-plugin": "^8.32.0",
18-
"@typescript-eslint/parser": "^8.32.0",
19-
"eslint": "^9.26.0",
20-
"eslint-config-prettier": "^10.1.3",
21-
"eslint-plugin-prettier": "^5.4.0",
17+
"@typescript-eslint/eslint-plugin": "^8.56.0",
18+
"@typescript-eslint/parser": "^8.56.0",
19+
"eslint": "^10.0.0",
20+
"eslint-config-prettier": "^10.1.8",
21+
"eslint-plugin-prettier": "^5.5.5",
2222
"typescript": "^5.8.3"
2323
},
2424
"dependencies": {
2525
"@broxus/await-semaphore": "^0.1.5",
26-
"bignumber.js": "^9.3.0",
26+
"bignumber.js": "^9.3.1",
2727
"events": "^3.3.0",
28-
"everscale-inpage-provider": "^0.6.3",
28+
"everscale-inpage-provider": "^0.6.5",
2929
"fast-safe-stringify": "^2.1.1",
30-
"nekoton-wasm": "^1.6.0",
31-
"node-fetch": "^2.6.7"
30+
"nekoton-wasm": "^1.8.2",
31+
"node-fetch": "^3.3.2"
3232
},
3333
"main": "./dist/cjs/index.js",
3434
"module": "./dist/esm/index.js",
@@ -59,4 +59,4 @@
5959
"files": [
6060
"./dist/*"
6161
]
62-
}
62+
}

src/client/AccountsStorage/EverWallet.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ export class EverWalletAccount implements Account {
103103
method,
104104
params,
105105
stateInit,
106-
signatureId: args.signatureId,
106+
signatureContext: args.signatureContext,
107107
});
108108
}
109109

@@ -139,7 +139,7 @@ export class EverWalletAccount implements Account {
139139
}
140140
}
141141

142-
const makeStateInit = (publicKey: BigNumber, nonce?: number): { boc: string, hash: string } => {
142+
const makeStateInit = (publicKey: BigNumber, nonce?: number): { boc: string; hash: string } => {
143143
let params: nt.AbiParam[], tokens: nt.TokensObject;
144144
if (nonce != null) {
145145
params = DATA_STRUCTURE_EXT;

src/client/AccountsStorage/Generic.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ export class GenericAccount implements Account {
5555
method,
5656
params,
5757
stateInit,
58-
signatureId: args.signatureId,
58+
signatureContext: args.signatureContext,
5959
});
6060
}
6161
}

src/client/AccountsStorage/Giver.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ export class GiverAccount implements Account {
8888
value: args.amount,
8989
bounce: args.bounce,
9090
},
91-
signatureId: args.signatureId,
91+
signatureContext: args.signatureContext,
9292
});
9393
}
9494
}

src/client/AccountsStorage/HighloadWalletV2.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ export class HighloadWalletV2 implements Account {
7979
params.messagesHash = `0x${messagesHash.slice(-8)}`;
8080

8181
const hash = ctx.packIntoCell({ structure: UNSIGNED_TRANSFER_STRUCTURE, data: params }).hash;
82-
const signature = await signer.sign(hash, args.signatureId);
82+
const signature = await signer.sign(hash, args.signatureContext);
8383
const { signatureParts } = ctx.extendSignature(signature);
8484

8585
params.signatureHigh = signatureParts.high;
@@ -139,7 +139,7 @@ const parseInitData = (ctx: AccountsStorageContext, boc: string): { publicKey: B
139139
};
140140
};
141141

142-
const makeStateInit = (publicKey: BigNumber): { boc: string, hash: string } => {
142+
const makeStateInit = (publicKey: BigNumber): { boc: string; hash: string } => {
143143
const data = core.nekoton.packIntoCell(DATA_STRUCTURE, {
144144
walletId: WALLET_ID,
145145
lastCleaned: 0,

src/client/AccountsStorage/WalletV3.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ export class WalletV3Account implements Account {
6868
};
6969

7070
const hash = ctx.packIntoCell({ structure: UNSIGNED_TRANSFER_STRUCTURE, data: params }).hash;
71-
const signature = await signer.sign(hash, args.signatureId);
71+
const signature = await signer.sign(hash, args.signatureContext);
7272
const { signatureParts } = ctx.extendSignature(signature);
7373

7474
params.signatureHigh = signatureParts.high;
@@ -139,7 +139,7 @@ const parseInitData = (ctx: AccountsStorageContext, boc: string): { seqno: numbe
139139
};
140140
};
141141

142-
const makeStateInit = (publicKey: BigNumber): { boc: string, hash: string } => {
142+
const makeStateInit = (publicKey: BigNumber): { boc: string; hash: string } => {
143143
const data = core.nekoton.packIntoCell(DATA_STRUCTURE, {
144144
seqno: 0,
145145
walletId: WALLET_ID,

src/client/AccountsStorage/index.ts

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import type * as ever from 'everscale-inpage-provider';
2-
import { AbiVersion, Address } from 'everscale-inpage-provider';
2+
import { AbiVersion, Address, SignatureContext } from 'everscale-inpage-provider';
33
import type * as nt from 'nekoton-wasm';
44

55
import { Keystore, Signer } from '../keystore';
@@ -82,9 +82,9 @@ export type PrepareMessageParams = {
8282
*/
8383
timeout: number;
8484
/**
85-
* Signature id for the current network
85+
* Signature context for the current network
8686
*/
87-
signatureId?: number;
87+
signatureContext: SignatureContext;
8888
};
8989

9090
/**
@@ -96,8 +96,7 @@ export class AccountsStorageContext {
9696
private readonly connectionController: ConnectionController,
9797
private readonly nekoton: typeof nt,
9898
private readonly keystore?: Keystore,
99-
) {
100-
}
99+
) {}
101100

102101
public async getSigner(publicKey: string): Promise<Signer> {
103102
if (this.keystore == null) {
@@ -137,8 +136,8 @@ export class AccountsStorageContext {
137136
}
138137

139138
public packIntoCell(args: { structure: nt.AbiParam[]; data: nt.TokensObject; abiVersion?: AbiVersion }): {
140-
boc: string,
141-
hash: string,
139+
boc: string;
140+
hash: string;
142141
} {
143142
return this.nekoton.packIntoCell(args.structure, args.data, args.abiVersion);
144143
}
@@ -183,7 +182,7 @@ export class AccountsStorageContext {
183182
method: string;
184183
params: nt.TokensObject;
185184
stateInit?: string;
186-
signatureId?: number;
185+
signatureContext?: SignatureContext;
187186
}): Promise<nt.SignedMessage> {
188187
const unsignedMessage = this.nekoton.createExternalMessage(
189188
this.clock,
@@ -197,7 +196,7 @@ export class AccountsStorageContext {
197196
);
198197

199198
try {
200-
const signature = await args.signer.sign(unsignedMessage.hash, args.signatureId);
199+
const signature = await args.signer.sign(unsignedMessage.hash, args.signatureContext);
201200
return unsignedMessage.sign(signature);
202201
} finally {
203202
unsignedMessage.free();

0 commit comments

Comments
 (0)