@ton-wallet/create 14.0.2 → 14.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/client/TonClient.d.ts +228 -0
- package/dist/client/TonClient.js +441 -0
- package/dist/client/TonClient.spec.d.ts +1 -0
- package/dist/client/TonClient.spec.js +45 -0
- package/dist/client/TonClient4.d.ts +1130 -0
- package/dist/client/TonClient4.js +687 -0
- package/dist/client/TonClient4.spec.d.ts +1 -0
- package/dist/client/TonClient4.spec.js +42 -0
- package/dist/client/api/HttpApi.d.ts +764 -0
- package/dist/client/api/HttpApi.js +306 -0
- package/dist/client/api/TonCache.d.ts +16 -0
- package/dist/client/api/TonCache.js +33 -0
- package/dist/config/ConfigParser.d.ts +622 -0
- package/dist/config/ConfigParser.js +711 -0
- package/dist/config/ConfigParser.spec.d.ts +8 -0
- package/dist/config/ConfigParser.spec.js +97 -0
- package/dist/elector/ElectorContract.d.ts +51 -0
- package/dist/elector/ElectorContract.js +192 -0
- package/dist/elector/ElectorContract.spec.d.ts +8 -0
- package/dist/elector/ElectorContract.spec.js +104 -0
- package/dist/index.d.ts +33 -0
- package/dist/index.js +129 -0
- package/dist/jetton/JettonMaster.d.ts +21 -0
- package/dist/jetton/JettonMaster.js +39 -0
- package/dist/jetton/JettonMaster.spec.d.ts +8 -0
- package/dist/jetton/JettonMaster.spec.js +27 -0
- package/dist/jetton/JettonWallet.d.ts +14 -0
- package/dist/jetton/JettonWallet.js +27 -0
- package/dist/multisig/MultisigOrder.d.ts +17 -0
- package/dist/multisig/MultisigOrder.js +73 -0
- package/dist/multisig/MultisigOrder.spec.d.ts +1 -0
- package/dist/multisig/MultisigOrder.spec.js +139 -0
- package/dist/multisig/MultisigOrderBuilder.d.ts +13 -0
- package/dist/multisig/MultisigOrderBuilder.js +37 -0
- package/dist/multisig/MultisigWallet.d.ts +27 -0
- package/dist/multisig/MultisigWallet.js +134 -0
- package/dist/multisig/MultisigWallet.spec.d.ts +1 -0
- package/dist/multisig/MultisigWallet.spec.js +248 -0
- package/dist/utils/createTestClient.d.ts +9 -0
- package/dist/utils/createTestClient.js +18 -0
- package/dist/utils/createTestClient4.d.ts +9 -0
- package/dist/utils/createTestClient4.js +15 -0
- package/dist/utils/fees.d.ts +25 -0
- package/dist/utils/fees.js +105 -0
- package/dist/utils/fees.spec.d.ts +1 -0
- package/dist/utils/fees.spec.js +83 -0
- package/dist/utils/maybe.d.ts +8 -0
- package/dist/utils/maybe.js +9 -0
- package/dist/utils/randomTestKey.d.ts +8 -0
- package/dist/utils/randomTestKey.js +24 -0
- package/dist/utils/time.d.ts +15 -0
- package/dist/utils/time.js +63 -0
- package/dist/utils/toUrlSafe.d.ts +8 -0
- package/dist/utils/toUrlSafe.js +23 -0
- package/dist/wallets/WalletContractV1R1.d.ts +58 -0
- package/dist/wallets/WalletContractV1R1.js +100 -0
- package/dist/wallets/WalletContractV1R1.spec.d.ts +8 -0
- package/dist/wallets/WalletContractV1R1.spec.js +44 -0
- package/dist/wallets/WalletContractV1R2.d.ts +58 -0
- package/dist/wallets/WalletContractV1R2.js +101 -0
- package/dist/wallets/WalletContractV1R2.spec.d.ts +8 -0
- package/dist/wallets/WalletContractV1R2.spec.js +44 -0
- package/dist/wallets/WalletContractV1R3.d.ts +58 -0
- package/dist/wallets/WalletContractV1R3.js +101 -0
- package/dist/wallets/WalletContractV1R3.spec.d.ts +8 -0
- package/dist/wallets/WalletContractV1R3.spec.js +44 -0
- package/dist/wallets/WalletContractV2R1.d.ts +60 -0
- package/dist/wallets/WalletContractV2R1.js +102 -0
- package/dist/wallets/WalletContractV2R1.spec.d.ts +8 -0
- package/dist/wallets/WalletContractV2R1.spec.js +44 -0
- package/dist/wallets/WalletContractV2R2.d.ts +60 -0
- package/dist/wallets/WalletContractV2R2.js +102 -0
- package/dist/wallets/WalletContractV2R2.spec.d.ts +8 -0
- package/dist/wallets/WalletContractV2R2.spec.js +44 -0
- package/dist/wallets/WalletContractV3R1.d.ts +57 -0
- package/dist/wallets/WalletContractV3R1.js +104 -0
- package/dist/wallets/WalletContractV3R1.spec.d.ts +8 -0
- package/dist/wallets/WalletContractV3R1.spec.js +44 -0
- package/dist/wallets/WalletContractV3R2.d.ts +57 -0
- package/dist/wallets/WalletContractV3R2.js +104 -0
- package/dist/wallets/WalletContractV3R2.spec.d.ts +8 -0
- package/dist/wallets/WalletContractV3R2.spec.js +44 -0
- package/dist/wallets/WalletContractV3Types.d.ts +12 -0
- package/dist/wallets/WalletContractV3Types.js +2 -0
- package/dist/wallets/WalletContractV4.d.ts +65 -0
- package/dist/wallets/WalletContractV4.js +105 -0
- package/dist/wallets/WalletContractV4.spec.d.ts +8 -0
- package/dist/wallets/WalletContractV4.spec.js +48 -0
- package/dist/wallets/WalletContractV5Beta.d.ts +3 -0
- package/dist/wallets/WalletContractV5Beta.js +19 -0
- package/dist/wallets/WalletContractV5R1.d.ts +3 -0
- package/dist/wallets/WalletContractV5R1.js +19 -0
- package/dist/wallets/signing/createWalletTransfer.d.ts +48 -0
- package/dist/wallets/signing/createWalletTransfer.js +190 -0
- package/dist/wallets/signing/singer.d.ts +9 -0
- package/dist/wallets/signing/singer.js +21 -0
- package/dist/wallets/v5beta/WalletContractV5Beta.d.ts +130 -0
- package/dist/wallets/v5beta/WalletContractV5Beta.js +211 -0
- package/dist/wallets/v5beta/WalletContractV5Beta.spec.d.ts +8 -0
- package/dist/wallets/v5beta/WalletContractV5Beta.spec.js +298 -0
- package/dist/wallets/v5beta/WalletV5BetaActions.d.ts +6 -0
- package/dist/wallets/v5beta/WalletV5BetaActions.js +92 -0
- package/dist/wallets/v5beta/WalletV5BetaActions.spec.d.ts +1 -0
- package/dist/wallets/v5beta/WalletV5BetaActions.spec.js +166 -0
- package/dist/wallets/v5beta/WalletV5BetaWalletId.d.ts +13 -0
- package/dist/wallets/v5beta/WalletV5BetaWalletId.js +31 -0
- package/dist/wallets/v5beta/WalletV5BetaWalletId.spec.d.ts +1 -0
- package/dist/wallets/v5beta/WalletV5BetaWalletId.spec.js +68 -0
- package/dist/wallets/v5beta/WalletV5OutActions.d.ts +17 -0
- package/dist/wallets/v5beta/WalletV5OutActions.js +11 -0
- package/dist/wallets/v5r1/WalletContractV5R1.d.ts +125 -0
- package/dist/wallets/v5r1/WalletContractV5R1.js +207 -0
- package/dist/wallets/v5r1/WalletContractV5R1.spec.d.ts +8 -0
- package/dist/wallets/v5r1/WalletContractV5R1.spec.js +321 -0
- package/dist/wallets/v5r1/WalletV5R1Actions.d.ts +12 -0
- package/dist/wallets/v5r1/WalletV5R1Actions.js +128 -0
- package/dist/wallets/v5r1/WalletV5R1Actions.spec.d.ts +1 -0
- package/dist/wallets/v5r1/WalletV5R1Actions.spec.js +262 -0
- package/dist/wallets/v5r1/WalletV5R1WalletId.d.ts +47 -0
- package/dist/wallets/v5r1/WalletV5R1WalletId.js +69 -0
- package/dist/wallets/v5r1/WalletV5R1WalletId.spec.d.ts +1 -0
- package/dist/wallets/v5r1/WalletV5R1WalletId.spec.js +72 -0
- package/package.json +5 -2
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) Whales Corp.
|
|
3
|
+
* All Rights Reserved.
|
|
4
|
+
*
|
|
5
|
+
* This source code is licensed under the MIT license found in the
|
|
6
|
+
* LICENSE file in the root directory of this source tree.
|
|
7
|
+
*/
|
|
8
|
+
/// <reference types="node" />
|
|
9
|
+
import { Address, Cell, Contract, ContractProvider, MessageRelaxed, Sender, SendMode } from "@ton/core";
|
|
10
|
+
import { Maybe } from "../utils/maybe";
|
|
11
|
+
export declare class WalletContractV2R1 implements Contract {
|
|
12
|
+
static create(args: {
|
|
13
|
+
workchain: number;
|
|
14
|
+
publicKey: Buffer;
|
|
15
|
+
}): WalletContractV2R1;
|
|
16
|
+
readonly workchain: number;
|
|
17
|
+
readonly publicKey: Buffer;
|
|
18
|
+
readonly address: Address;
|
|
19
|
+
readonly init: {
|
|
20
|
+
data: Cell;
|
|
21
|
+
code: Cell;
|
|
22
|
+
};
|
|
23
|
+
private constructor();
|
|
24
|
+
/**
|
|
25
|
+
* Get Wallet Balance
|
|
26
|
+
*/
|
|
27
|
+
getBalance(provider: ContractProvider): Promise<bigint>;
|
|
28
|
+
/**
|
|
29
|
+
* Get Wallet Seqno
|
|
30
|
+
*/
|
|
31
|
+
getSeqno(provider: ContractProvider): Promise<number>;
|
|
32
|
+
/**
|
|
33
|
+
* Send signed transfer
|
|
34
|
+
*/
|
|
35
|
+
send(provider: ContractProvider, message: Cell): Promise<void>;
|
|
36
|
+
/**
|
|
37
|
+
* Sign and send transfer
|
|
38
|
+
*/
|
|
39
|
+
sendTransfer(provider: ContractProvider, args: {
|
|
40
|
+
seqno: number;
|
|
41
|
+
secretKey: Buffer;
|
|
42
|
+
messages: MessageRelaxed[];
|
|
43
|
+
sendMode?: Maybe<SendMode>;
|
|
44
|
+
timeout?: Maybe<number>;
|
|
45
|
+
}): Promise<void>;
|
|
46
|
+
/**
|
|
47
|
+
* Create signed transfer
|
|
48
|
+
*/
|
|
49
|
+
createTransfer(args: {
|
|
50
|
+
seqno: number;
|
|
51
|
+
secretKey: Buffer;
|
|
52
|
+
messages: MessageRelaxed[];
|
|
53
|
+
sendMode?: Maybe<SendMode>;
|
|
54
|
+
timeout?: Maybe<number>;
|
|
55
|
+
}): Cell;
|
|
56
|
+
/**
|
|
57
|
+
* Create sender
|
|
58
|
+
*/
|
|
59
|
+
sender(provider: ContractProvider, secretKey: Buffer): Sender;
|
|
60
|
+
}
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Copyright (c) Whales Corp.
|
|
4
|
+
* All Rights Reserved.
|
|
5
|
+
*
|
|
6
|
+
* This source code is licensed under the MIT license found in the
|
|
7
|
+
* LICENSE file in the root directory of this source tree.
|
|
8
|
+
*/
|
|
9
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
+
exports.WalletContractV2R1 = void 0;
|
|
11
|
+
const core_1 = require("@ton/core");
|
|
12
|
+
const createWalletTransfer_1 = require("./signing/createWalletTransfer");
|
|
13
|
+
class WalletContractV2R1 {
|
|
14
|
+
static create(args) {
|
|
15
|
+
return new WalletContractV2R1(args.workchain, args.publicKey);
|
|
16
|
+
}
|
|
17
|
+
constructor(workchain, publicKey) {
|
|
18
|
+
this.workchain = workchain;
|
|
19
|
+
this.publicKey = publicKey;
|
|
20
|
+
// Build initial code and data
|
|
21
|
+
let code = core_1.Cell.fromBoc(Buffer.from('te6cckEBAQEAVwAAqv8AIN0gggFMl7qXMO1E0NcLH+Ck8mCDCNcYINMf0x8B+CO78mPtRNDTH9P/0VExuvKhA/kBVBBC+RDyovgAApMg10qW0wfUAvsA6NGkyMsfy//J7VShNwu2', 'base64'))[0];
|
|
22
|
+
let data = (0, core_1.beginCell)()
|
|
23
|
+
.storeUint(0, 32) // Seqno
|
|
24
|
+
.storeBuffer(publicKey)
|
|
25
|
+
.endCell();
|
|
26
|
+
this.init = { code, data };
|
|
27
|
+
this.address = (0, core_1.contractAddress)(workchain, { code, data });
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Get Wallet Balance
|
|
31
|
+
*/
|
|
32
|
+
async getBalance(provider) {
|
|
33
|
+
let state = await provider.getState();
|
|
34
|
+
return state.balance;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Get Wallet Seqno
|
|
38
|
+
*/
|
|
39
|
+
async getSeqno(provider) {
|
|
40
|
+
let state = await provider.getState();
|
|
41
|
+
if (state.state.type === 'active') {
|
|
42
|
+
let res = await provider.get('seqno', []);
|
|
43
|
+
return res.stack.readNumber();
|
|
44
|
+
}
|
|
45
|
+
else {
|
|
46
|
+
return 0;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Send signed transfer
|
|
51
|
+
*/
|
|
52
|
+
async send(provider, message) {
|
|
53
|
+
await provider.external(message);
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Sign and send transfer
|
|
57
|
+
*/
|
|
58
|
+
async sendTransfer(provider, args) {
|
|
59
|
+
let transfer = this.createTransfer(args);
|
|
60
|
+
await this.send(provider, transfer);
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Create signed transfer
|
|
64
|
+
*/
|
|
65
|
+
createTransfer(args) {
|
|
66
|
+
let sendMode = core_1.SendMode.PAY_GAS_SEPARATELY;
|
|
67
|
+
if (args.sendMode !== null && args.sendMode !== undefined) {
|
|
68
|
+
sendMode = args.sendMode;
|
|
69
|
+
}
|
|
70
|
+
return (0, createWalletTransfer_1.createWalletTransferV2)({
|
|
71
|
+
seqno: args.seqno,
|
|
72
|
+
sendMode,
|
|
73
|
+
secretKey: args.secretKey,
|
|
74
|
+
messages: args.messages,
|
|
75
|
+
timeout: args.timeout
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Create sender
|
|
80
|
+
*/
|
|
81
|
+
sender(provider, secretKey) {
|
|
82
|
+
return {
|
|
83
|
+
send: async (args) => {
|
|
84
|
+
let seqno = await this.getSeqno(provider);
|
|
85
|
+
let transfer = this.createTransfer({
|
|
86
|
+
seqno,
|
|
87
|
+
secretKey,
|
|
88
|
+
sendMode: args.sendMode,
|
|
89
|
+
messages: [(0, core_1.internal)({
|
|
90
|
+
to: args.to,
|
|
91
|
+
value: args.value,
|
|
92
|
+
init: args.init,
|
|
93
|
+
body: args.body,
|
|
94
|
+
bounce: args.bounce
|
|
95
|
+
})]
|
|
96
|
+
});
|
|
97
|
+
await this.send(provider, transfer);
|
|
98
|
+
}
|
|
99
|
+
};
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
exports.WalletContractV2R1 = WalletContractV2R1;
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Copyright (c) Whales Corp.
|
|
4
|
+
* All Rights Reserved.
|
|
5
|
+
*
|
|
6
|
+
* This source code is licensed under the MIT license found in the
|
|
7
|
+
* LICENSE file in the root directory of this source tree.
|
|
8
|
+
*/
|
|
9
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
+
const randomTestKey_1 = require("../utils/randomTestKey");
|
|
11
|
+
const createTestClient4_1 = require("../utils/createTestClient4");
|
|
12
|
+
const core_1 = require("@ton/core");
|
|
13
|
+
const WalletContractV2R1_1 = require("./WalletContractV2R1");
|
|
14
|
+
describe('WalletContractV2R1', () => {
|
|
15
|
+
it('should has balance and correct address', async () => {
|
|
16
|
+
// Create contract
|
|
17
|
+
let client = (0, createTestClient4_1.createTestClient4)();
|
|
18
|
+
let key = (0, randomTestKey_1.randomTestKey)('v4-treasure');
|
|
19
|
+
let contract = client.open(WalletContractV2R1_1.WalletContractV2R1.create({ workchain: 0, publicKey: key.publicKey }));
|
|
20
|
+
let balance = await contract.getBalance();
|
|
21
|
+
// Check parameters
|
|
22
|
+
expect(contract.address.equals(core_1.Address.parse('EQD3ES67JiTYq5y2eE1-fivl5kANn-gKDDjvpbxNCQWPzs4D'))).toBe(true);
|
|
23
|
+
expect(balance > 0n).toBe(true);
|
|
24
|
+
});
|
|
25
|
+
it('should perform transfer', async () => {
|
|
26
|
+
// Create contract
|
|
27
|
+
let client = (0, createTestClient4_1.createTestClient4)();
|
|
28
|
+
let key = (0, randomTestKey_1.randomTestKey)('v4-treasure');
|
|
29
|
+
let contract = client.open(WalletContractV2R1_1.WalletContractV2R1.create({ workchain: 0, publicKey: key.publicKey }));
|
|
30
|
+
// Prepare transfer
|
|
31
|
+
let seqno = await contract.getSeqno();
|
|
32
|
+
let transfer = contract.createTransfer({
|
|
33
|
+
seqno,
|
|
34
|
+
secretKey: key.secretKey,
|
|
35
|
+
messages: [(0, core_1.internal)({
|
|
36
|
+
to: 'kQD6oPnzaaAMRW24R8F0_nlSsJQni0cGHntR027eT9_sgtwt',
|
|
37
|
+
value: '0.1',
|
|
38
|
+
body: 'Hello, world!'
|
|
39
|
+
})]
|
|
40
|
+
});
|
|
41
|
+
// Perform transfer
|
|
42
|
+
await contract.send(transfer);
|
|
43
|
+
});
|
|
44
|
+
});
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) Whales Corp.
|
|
3
|
+
* All Rights Reserved.
|
|
4
|
+
*
|
|
5
|
+
* This source code is licensed under the MIT license found in the
|
|
6
|
+
* LICENSE file in the root directory of this source tree.
|
|
7
|
+
*/
|
|
8
|
+
/// <reference types="node" />
|
|
9
|
+
import { Address, Cell, Contract, ContractProvider, MessageRelaxed, Sender, SendMode } from "@ton/core";
|
|
10
|
+
import { Maybe } from "../utils/maybe";
|
|
11
|
+
export declare class WalletContractV2R2 implements Contract {
|
|
12
|
+
static create(args: {
|
|
13
|
+
workchain: number;
|
|
14
|
+
publicKey: Buffer;
|
|
15
|
+
}): WalletContractV2R2;
|
|
16
|
+
readonly workchain: number;
|
|
17
|
+
readonly publicKey: Buffer;
|
|
18
|
+
readonly address: Address;
|
|
19
|
+
readonly init: {
|
|
20
|
+
data: Cell;
|
|
21
|
+
code: Cell;
|
|
22
|
+
};
|
|
23
|
+
private constructor();
|
|
24
|
+
/**
|
|
25
|
+
* Get Wallet Balance
|
|
26
|
+
*/
|
|
27
|
+
getBalance(provider: ContractProvider): Promise<bigint>;
|
|
28
|
+
/**
|
|
29
|
+
* Get Wallet Seqno
|
|
30
|
+
*/
|
|
31
|
+
getSeqno(provider: ContractProvider): Promise<number>;
|
|
32
|
+
/**
|
|
33
|
+
* Send signed transfer
|
|
34
|
+
*/
|
|
35
|
+
send(provider: ContractProvider, message: Cell): Promise<void>;
|
|
36
|
+
/**
|
|
37
|
+
* Sign and send transfer
|
|
38
|
+
*/
|
|
39
|
+
sendTransfer(provider: ContractProvider, args: {
|
|
40
|
+
seqno: number;
|
|
41
|
+
secretKey: Buffer;
|
|
42
|
+
messages: MessageRelaxed[];
|
|
43
|
+
sendMode?: Maybe<SendMode>;
|
|
44
|
+
timeout?: Maybe<number>;
|
|
45
|
+
}): Promise<void>;
|
|
46
|
+
/**
|
|
47
|
+
* Create signed transfer
|
|
48
|
+
*/
|
|
49
|
+
createTransfer(args: {
|
|
50
|
+
seqno: number;
|
|
51
|
+
secretKey: Buffer;
|
|
52
|
+
messages: MessageRelaxed[];
|
|
53
|
+
sendMode?: Maybe<SendMode>;
|
|
54
|
+
timeout?: Maybe<number>;
|
|
55
|
+
}): Cell;
|
|
56
|
+
/**
|
|
57
|
+
* Create sender
|
|
58
|
+
*/
|
|
59
|
+
sender(provider: ContractProvider, secretKey: Buffer): Sender;
|
|
60
|
+
}
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Copyright (c) Whales Corp.
|
|
4
|
+
* All Rights Reserved.
|
|
5
|
+
*
|
|
6
|
+
* This source code is licensed under the MIT license found in the
|
|
7
|
+
* LICENSE file in the root directory of this source tree.
|
|
8
|
+
*/
|
|
9
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
+
exports.WalletContractV2R2 = void 0;
|
|
11
|
+
const core_1 = require("@ton/core");
|
|
12
|
+
const createWalletTransfer_1 = require("./signing/createWalletTransfer");
|
|
13
|
+
class WalletContractV2R2 {
|
|
14
|
+
static create(args) {
|
|
15
|
+
return new WalletContractV2R2(args.workchain, args.publicKey);
|
|
16
|
+
}
|
|
17
|
+
constructor(workchain, publicKey) {
|
|
18
|
+
this.workchain = workchain;
|
|
19
|
+
this.publicKey = publicKey;
|
|
20
|
+
// Build initial code and data
|
|
21
|
+
let code = core_1.Cell.fromBoc(Buffer.from('te6cckEBAQEAYwAAwv8AIN0gggFMl7ohggEznLqxnHGw7UTQ0x/XC//jBOCk8mCDCNcYINMf0x8B+CO78mPtRNDTH9P/0VExuvKhA/kBVBBC+RDyovgAApMg10qW0wfUAvsA6NGkyMsfy//J7VQETNeh', 'base64'))[0];
|
|
22
|
+
let data = (0, core_1.beginCell)()
|
|
23
|
+
.storeUint(0, 32) // Seqno
|
|
24
|
+
.storeBuffer(publicKey)
|
|
25
|
+
.endCell();
|
|
26
|
+
this.init = { code, data };
|
|
27
|
+
this.address = (0, core_1.contractAddress)(workchain, { code, data });
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Get Wallet Balance
|
|
31
|
+
*/
|
|
32
|
+
async getBalance(provider) {
|
|
33
|
+
let state = await provider.getState();
|
|
34
|
+
return state.balance;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Get Wallet Seqno
|
|
38
|
+
*/
|
|
39
|
+
async getSeqno(provider) {
|
|
40
|
+
let state = await provider.getState();
|
|
41
|
+
if (state.state.type === 'active') {
|
|
42
|
+
let res = await provider.get('seqno', []);
|
|
43
|
+
return res.stack.readNumber();
|
|
44
|
+
}
|
|
45
|
+
else {
|
|
46
|
+
return 0;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Send signed transfer
|
|
51
|
+
*/
|
|
52
|
+
async send(provider, message) {
|
|
53
|
+
await provider.external(message);
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Sign and send transfer
|
|
57
|
+
*/
|
|
58
|
+
async sendTransfer(provider, args) {
|
|
59
|
+
let transfer = this.createTransfer(args);
|
|
60
|
+
await this.send(provider, transfer);
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Create signed transfer
|
|
64
|
+
*/
|
|
65
|
+
createTransfer(args) {
|
|
66
|
+
let sendMode = core_1.SendMode.PAY_GAS_SEPARATELY;
|
|
67
|
+
if (args.sendMode !== null && args.sendMode !== undefined) {
|
|
68
|
+
sendMode = args.sendMode;
|
|
69
|
+
}
|
|
70
|
+
return (0, createWalletTransfer_1.createWalletTransferV2)({
|
|
71
|
+
seqno: args.seqno,
|
|
72
|
+
sendMode,
|
|
73
|
+
secretKey: args.secretKey,
|
|
74
|
+
messages: args.messages,
|
|
75
|
+
timeout: args.timeout
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Create sender
|
|
80
|
+
*/
|
|
81
|
+
sender(provider, secretKey) {
|
|
82
|
+
return {
|
|
83
|
+
send: async (args) => {
|
|
84
|
+
let seqno = await this.getSeqno(provider);
|
|
85
|
+
let transfer = this.createTransfer({
|
|
86
|
+
seqno,
|
|
87
|
+
secretKey,
|
|
88
|
+
sendMode: args.sendMode,
|
|
89
|
+
messages: [(0, core_1.internal)({
|
|
90
|
+
to: args.to,
|
|
91
|
+
value: args.value,
|
|
92
|
+
init: args.init,
|
|
93
|
+
body: args.body,
|
|
94
|
+
bounce: args.bounce
|
|
95
|
+
})]
|
|
96
|
+
});
|
|
97
|
+
await this.send(provider, transfer);
|
|
98
|
+
}
|
|
99
|
+
};
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
exports.WalletContractV2R2 = WalletContractV2R2;
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Copyright (c) Whales Corp.
|
|
4
|
+
* All Rights Reserved.
|
|
5
|
+
*
|
|
6
|
+
* This source code is licensed under the MIT license found in the
|
|
7
|
+
* LICENSE file in the root directory of this source tree.
|
|
8
|
+
*/
|
|
9
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
+
const randomTestKey_1 = require("../utils/randomTestKey");
|
|
11
|
+
const createTestClient4_1 = require("../utils/createTestClient4");
|
|
12
|
+
const core_1 = require("@ton/core");
|
|
13
|
+
const WalletContractV2R2_1 = require("./WalletContractV2R2");
|
|
14
|
+
describe('WalletContractV2R2', () => {
|
|
15
|
+
it('should has balance and correct address', async () => {
|
|
16
|
+
// Create contract
|
|
17
|
+
let client = (0, createTestClient4_1.createTestClient4)();
|
|
18
|
+
let key = (0, randomTestKey_1.randomTestKey)('v4-treasure');
|
|
19
|
+
let contract = client.open(WalletContractV2R2_1.WalletContractV2R2.create({ workchain: 0, publicKey: key.publicKey }));
|
|
20
|
+
let balance = await contract.getBalance();
|
|
21
|
+
// Check parameters
|
|
22
|
+
expect(contract.address.equals(core_1.Address.parse('EQAkAcNLtzCHudScK9Hsk9I_7SrunBWf_9VrA2xJmGebwEsl'))).toBe(true);
|
|
23
|
+
expect(balance > 0n).toBe(true);
|
|
24
|
+
});
|
|
25
|
+
it('should perform transfer', async () => {
|
|
26
|
+
// Create contract
|
|
27
|
+
let client = (0, createTestClient4_1.createTestClient4)();
|
|
28
|
+
let key = (0, randomTestKey_1.randomTestKey)('v4-treasure');
|
|
29
|
+
let contract = client.open(WalletContractV2R2_1.WalletContractV2R2.create({ workchain: 0, publicKey: key.publicKey }));
|
|
30
|
+
// Prepare transfer
|
|
31
|
+
let seqno = await contract.getSeqno();
|
|
32
|
+
let transfer = contract.createTransfer({
|
|
33
|
+
seqno,
|
|
34
|
+
secretKey: key.secretKey,
|
|
35
|
+
messages: [(0, core_1.internal)({
|
|
36
|
+
to: 'kQD6oPnzaaAMRW24R8F0_nlSsJQni0cGHntR027eT9_sgtwt',
|
|
37
|
+
value: '0.1',
|
|
38
|
+
body: 'Hello, world!'
|
|
39
|
+
})]
|
|
40
|
+
});
|
|
41
|
+
// Perform transfer
|
|
42
|
+
await contract.send(transfer);
|
|
43
|
+
});
|
|
44
|
+
});
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) Whales Corp.
|
|
3
|
+
* All Rights Reserved.
|
|
4
|
+
*
|
|
5
|
+
* This source code is licensed under the MIT license found in the
|
|
6
|
+
* LICENSE file in the root directory of this source tree.
|
|
7
|
+
*/
|
|
8
|
+
/// <reference types="node" />
|
|
9
|
+
import { Address, Cell, Contract, ContractProvider, MessageRelaxed, Sender, SendMode } from "@ton/core";
|
|
10
|
+
import { Maybe } from "../utils/maybe";
|
|
11
|
+
import { WalletV3SendArgsSignable, WalletV3SendArgsSigned } from "./WalletContractV3Types";
|
|
12
|
+
export declare class WalletContractV3R1 implements Contract {
|
|
13
|
+
static create(args: {
|
|
14
|
+
workchain: number;
|
|
15
|
+
publicKey: Buffer;
|
|
16
|
+
walletId?: Maybe<number>;
|
|
17
|
+
}): WalletContractV3R1;
|
|
18
|
+
readonly workchain: number;
|
|
19
|
+
readonly publicKey: Buffer;
|
|
20
|
+
readonly address: Address;
|
|
21
|
+
readonly walletId: number;
|
|
22
|
+
readonly init: {
|
|
23
|
+
data: Cell;
|
|
24
|
+
code: Cell;
|
|
25
|
+
};
|
|
26
|
+
private constructor();
|
|
27
|
+
/**
|
|
28
|
+
* Get wallet balance
|
|
29
|
+
*/
|
|
30
|
+
getBalance(provider: ContractProvider): Promise<bigint>;
|
|
31
|
+
/**
|
|
32
|
+
* Get Wallet Seqno
|
|
33
|
+
*/
|
|
34
|
+
getSeqno(provider: ContractProvider): Promise<number>;
|
|
35
|
+
/**
|
|
36
|
+
* Send signed transfer
|
|
37
|
+
*/
|
|
38
|
+
send(provider: ContractProvider, message: Cell): Promise<void>;
|
|
39
|
+
/**
|
|
40
|
+
* Sign and send transfer
|
|
41
|
+
*/
|
|
42
|
+
sendTransfer(provider: ContractProvider, args: {
|
|
43
|
+
seqno: number;
|
|
44
|
+
secretKey: Buffer;
|
|
45
|
+
messages: MessageRelaxed[];
|
|
46
|
+
sendMode?: Maybe<SendMode>;
|
|
47
|
+
timeout?: Maybe<number>;
|
|
48
|
+
}): Promise<void>;
|
|
49
|
+
/**
|
|
50
|
+
* Create transfer
|
|
51
|
+
*/
|
|
52
|
+
createTransfer<T extends WalletV3SendArgsSigned | WalletV3SendArgsSignable>(args: T): T extends WalletV3SendArgsSignable ? Promise<Cell> : Cell;
|
|
53
|
+
/**
|
|
54
|
+
* Create sender
|
|
55
|
+
*/
|
|
56
|
+
sender(provider: ContractProvider, secretKey: Buffer): Sender;
|
|
57
|
+
}
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Copyright (c) Whales Corp.
|
|
4
|
+
* All Rights Reserved.
|
|
5
|
+
*
|
|
6
|
+
* This source code is licensed under the MIT license found in the
|
|
7
|
+
* LICENSE file in the root directory of this source tree.
|
|
8
|
+
*/
|
|
9
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
+
exports.WalletContractV3R1 = void 0;
|
|
11
|
+
const core_1 = require("@ton/core");
|
|
12
|
+
const createWalletTransfer_1 = require("./signing/createWalletTransfer");
|
|
13
|
+
class WalletContractV3R1 {
|
|
14
|
+
static create(args) {
|
|
15
|
+
return new WalletContractV3R1(args.workchain, args.publicKey, args.walletId);
|
|
16
|
+
}
|
|
17
|
+
constructor(workchain, publicKey, walletId) {
|
|
18
|
+
// Resolve parameters
|
|
19
|
+
this.workchain = workchain;
|
|
20
|
+
this.publicKey = publicKey;
|
|
21
|
+
if (walletId !== null && walletId !== undefined) {
|
|
22
|
+
this.walletId = walletId;
|
|
23
|
+
}
|
|
24
|
+
else {
|
|
25
|
+
this.walletId = 698983191 + workchain;
|
|
26
|
+
}
|
|
27
|
+
// Build initial code and data
|
|
28
|
+
let code = core_1.Cell.fromBoc(Buffer.from('te6cckEBAQEAYgAAwP8AIN0gggFMl7qXMO1E0NcLH+Ck8mCDCNcYINMf0x/TH/gjE7vyY+1E0NMf0x/T/9FRMrryoVFEuvKiBPkBVBBV+RDyo/gAkyDXSpbTB9QC+wDo0QGkyMsfyx/L/8ntVD++buA=', 'base64'))[0];
|
|
29
|
+
let data = (0, core_1.beginCell)()
|
|
30
|
+
.storeUint(0, 32) // Seqno
|
|
31
|
+
.storeUint(this.walletId, 32)
|
|
32
|
+
.storeBuffer(publicKey)
|
|
33
|
+
.endCell();
|
|
34
|
+
this.init = { code, data };
|
|
35
|
+
this.address = (0, core_1.contractAddress)(workchain, { code, data });
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Get wallet balance
|
|
39
|
+
*/
|
|
40
|
+
async getBalance(provider) {
|
|
41
|
+
let state = await provider.getState();
|
|
42
|
+
return state.balance;
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Get Wallet Seqno
|
|
46
|
+
*/
|
|
47
|
+
async getSeqno(provider) {
|
|
48
|
+
let state = await provider.getState();
|
|
49
|
+
if (state.state.type === 'active') {
|
|
50
|
+
let res = await provider.get('seqno', []);
|
|
51
|
+
return res.stack.readNumber();
|
|
52
|
+
}
|
|
53
|
+
else {
|
|
54
|
+
return 0;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Send signed transfer
|
|
59
|
+
*/
|
|
60
|
+
async send(provider, message) {
|
|
61
|
+
await provider.external(message);
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Sign and send transfer
|
|
65
|
+
*/
|
|
66
|
+
async sendTransfer(provider, args) {
|
|
67
|
+
let transfer = this.createTransfer(args);
|
|
68
|
+
await this.send(provider, transfer);
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Create transfer
|
|
72
|
+
*/
|
|
73
|
+
createTransfer(args) {
|
|
74
|
+
return (0, createWalletTransfer_1.createWalletTransferV3)({
|
|
75
|
+
...args,
|
|
76
|
+
sendMode: args.sendMode ?? core_1.SendMode.PAY_GAS_SEPARATELY,
|
|
77
|
+
walletId: this.walletId
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* Create sender
|
|
82
|
+
*/
|
|
83
|
+
sender(provider, secretKey) {
|
|
84
|
+
return {
|
|
85
|
+
send: async (args) => {
|
|
86
|
+
let seqno = await this.getSeqno(provider);
|
|
87
|
+
let transfer = this.createTransfer({
|
|
88
|
+
seqno,
|
|
89
|
+
secretKey,
|
|
90
|
+
sendMode: args.sendMode,
|
|
91
|
+
messages: [(0, core_1.internal)({
|
|
92
|
+
to: args.to,
|
|
93
|
+
value: args.value,
|
|
94
|
+
init: args.init,
|
|
95
|
+
body: args.body,
|
|
96
|
+
bounce: args.bounce
|
|
97
|
+
})]
|
|
98
|
+
});
|
|
99
|
+
await this.send(provider, transfer);
|
|
100
|
+
}
|
|
101
|
+
};
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
exports.WalletContractV3R1 = WalletContractV3R1;
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Copyright (c) Whales Corp.
|
|
4
|
+
* All Rights Reserved.
|
|
5
|
+
*
|
|
6
|
+
* This source code is licensed under the MIT license found in the
|
|
7
|
+
* LICENSE file in the root directory of this source tree.
|
|
8
|
+
*/
|
|
9
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
+
const randomTestKey_1 = require("../utils/randomTestKey");
|
|
11
|
+
const createTestClient4_1 = require("../utils/createTestClient4");
|
|
12
|
+
const core_1 = require("@ton/core");
|
|
13
|
+
const WalletContractV3R1_1 = require("./WalletContractV3R1");
|
|
14
|
+
describe('WalletContractV3R1', () => {
|
|
15
|
+
it('should has balance and correct address', async () => {
|
|
16
|
+
// Create contract
|
|
17
|
+
let client = (0, createTestClient4_1.createTestClient4)();
|
|
18
|
+
let key = (0, randomTestKey_1.randomTestKey)('v4-treasure');
|
|
19
|
+
let contract = client.open(WalletContractV3R1_1.WalletContractV3R1.create({ workchain: 0, publicKey: key.publicKey }));
|
|
20
|
+
let balance = await contract.getBalance();
|
|
21
|
+
// Check parameters
|
|
22
|
+
expect(contract.address.equals(core_1.Address.parse('EQBJp7j5N40GXJbAqFSnfTV1Af4ZTyHIMpRbKcudNhWJbbNO'))).toBe(true);
|
|
23
|
+
expect(balance > 0n).toBe(true);
|
|
24
|
+
});
|
|
25
|
+
it('should perform transfer', async () => {
|
|
26
|
+
// Create contract
|
|
27
|
+
let client = (0, createTestClient4_1.createTestClient4)();
|
|
28
|
+
let key = (0, randomTestKey_1.randomTestKey)('v4-treasure');
|
|
29
|
+
let contract = client.open(WalletContractV3R1_1.WalletContractV3R1.create({ workchain: 0, publicKey: key.publicKey }));
|
|
30
|
+
// Prepare transfer
|
|
31
|
+
let seqno = await contract.getSeqno();
|
|
32
|
+
let transfer = contract.createTransfer({
|
|
33
|
+
seqno,
|
|
34
|
+
secretKey: key.secretKey,
|
|
35
|
+
messages: [(0, core_1.internal)({
|
|
36
|
+
to: 'kQD6oPnzaaAMRW24R8F0_nlSsJQni0cGHntR027eT9_sgtwt',
|
|
37
|
+
value: '0.1',
|
|
38
|
+
body: 'Hello, world!'
|
|
39
|
+
})]
|
|
40
|
+
});
|
|
41
|
+
// Perform transfer
|
|
42
|
+
await contract.send(transfer);
|
|
43
|
+
});
|
|
44
|
+
});
|