@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,23 @@
|
|
|
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.toUrlSafe = void 0;
|
|
11
|
+
function toUrlSafe(src) {
|
|
12
|
+
while (src.indexOf('/') >= 0) {
|
|
13
|
+
src = src.replace('/', '_');
|
|
14
|
+
}
|
|
15
|
+
while (src.indexOf('+') >= 0) {
|
|
16
|
+
src = src.replace('+', '-');
|
|
17
|
+
}
|
|
18
|
+
while (src.indexOf('=') >= 0) {
|
|
19
|
+
src = src.replace('=', '');
|
|
20
|
+
}
|
|
21
|
+
return src;
|
|
22
|
+
}
|
|
23
|
+
exports.toUrlSafe = toUrlSafe;
|
|
@@ -0,0 +1,58 @@
|
|
|
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 WalletContractV1R1 implements Contract {
|
|
12
|
+
static create(args: {
|
|
13
|
+
workchain: number;
|
|
14
|
+
publicKey: Buffer;
|
|
15
|
+
}): WalletContractV1R1;
|
|
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
|
+
message?: Maybe<MessageRelaxed>;
|
|
43
|
+
sendMode?: Maybe<SendMode>;
|
|
44
|
+
}): Promise<void>;
|
|
45
|
+
/**
|
|
46
|
+
* Create signed transfer
|
|
47
|
+
*/
|
|
48
|
+
createTransfer(args: {
|
|
49
|
+
seqno: number;
|
|
50
|
+
secretKey: Buffer;
|
|
51
|
+
message?: Maybe<MessageRelaxed>;
|
|
52
|
+
sendMode?: Maybe<SendMode>;
|
|
53
|
+
}): Cell;
|
|
54
|
+
/**
|
|
55
|
+
* Create sender
|
|
56
|
+
*/
|
|
57
|
+
sender(provider: ContractProvider, secretKey: Buffer): Sender;
|
|
58
|
+
}
|
|
@@ -0,0 +1,100 @@
|
|
|
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.WalletContractV1R1 = void 0;
|
|
11
|
+
const core_1 = require("@ton/core");
|
|
12
|
+
const createWalletTransfer_1 = require("./signing/createWalletTransfer");
|
|
13
|
+
class WalletContractV1R1 {
|
|
14
|
+
static create(args) {
|
|
15
|
+
return new WalletContractV1R1(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('te6cckEBAQEARAAAhP8AIN2k8mCBAgDXGCDXCx/tRNDTH9P/0VESuvKhIvkBVBBE+RDyovgAAdMfMSDXSpbTB9QC+wDe0aTIyx/L/8ntVEH98Ik=', '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
|
+
return core_1.Cell.fromBoc(state.state.data)[0].beginParse().loadUint(32);
|
|
43
|
+
}
|
|
44
|
+
else {
|
|
45
|
+
return 0;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Send signed transfer
|
|
50
|
+
*/
|
|
51
|
+
async send(provider, message) {
|
|
52
|
+
await provider.external(message);
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Sign and send transfer
|
|
56
|
+
*/
|
|
57
|
+
async sendTransfer(provider, args) {
|
|
58
|
+
let transfer = this.createTransfer(args);
|
|
59
|
+
await this.send(provider, transfer);
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Create signed transfer
|
|
63
|
+
*/
|
|
64
|
+
createTransfer(args) {
|
|
65
|
+
let sendMode = core_1.SendMode.PAY_GAS_SEPARATELY;
|
|
66
|
+
if (args.sendMode !== null && args.sendMode !== undefined) {
|
|
67
|
+
sendMode = args.sendMode;
|
|
68
|
+
}
|
|
69
|
+
return (0, createWalletTransfer_1.createWalletTransferV1)({
|
|
70
|
+
seqno: args.seqno,
|
|
71
|
+
sendMode,
|
|
72
|
+
secretKey: args.secretKey,
|
|
73
|
+
message: args.message
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Create sender
|
|
78
|
+
*/
|
|
79
|
+
sender(provider, secretKey) {
|
|
80
|
+
return {
|
|
81
|
+
send: async (args) => {
|
|
82
|
+
let seqno = await this.getSeqno(provider);
|
|
83
|
+
let transfer = this.createTransfer({
|
|
84
|
+
seqno,
|
|
85
|
+
secretKey,
|
|
86
|
+
sendMode: args.sendMode,
|
|
87
|
+
message: (0, core_1.internal)({
|
|
88
|
+
to: args.to,
|
|
89
|
+
value: args.value,
|
|
90
|
+
init: args.init,
|
|
91
|
+
body: args.body,
|
|
92
|
+
bounce: args.bounce
|
|
93
|
+
})
|
|
94
|
+
});
|
|
95
|
+
await this.send(provider, transfer);
|
|
96
|
+
}
|
|
97
|
+
};
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
exports.WalletContractV1R1 = WalletContractV1R1;
|
|
@@ -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 WalletContractV1R1_1 = require("./WalletContractV1R1");
|
|
14
|
+
describe('WalletContractV1R1', () => {
|
|
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(WalletContractV1R1_1.WalletContractV1R1.create({ workchain: 0, publicKey: key.publicKey }));
|
|
20
|
+
let balance = await contract.getBalance();
|
|
21
|
+
// Check parameters
|
|
22
|
+
expect(contract.address.equals(core_1.Address.parse('EQCtW_zzk6n82ebaVQFq8P_04wOemYhtwqMd3NuArmPODRvD'))).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(WalletContractV1R1_1.WalletContractV1R1.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
|
+
message: (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,58 @@
|
|
|
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 WalletContractV1R2 implements Contract {
|
|
12
|
+
static create(args: {
|
|
13
|
+
workchain: number;
|
|
14
|
+
publicKey: Buffer;
|
|
15
|
+
}): WalletContractV1R2;
|
|
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
|
+
message?: Maybe<MessageRelaxed>;
|
|
43
|
+
sendMode?: Maybe<SendMode>;
|
|
44
|
+
}): Promise<void>;
|
|
45
|
+
/**
|
|
46
|
+
* Create signed transfer
|
|
47
|
+
*/
|
|
48
|
+
createTransfer(args: {
|
|
49
|
+
seqno: number;
|
|
50
|
+
secretKey: Buffer;
|
|
51
|
+
message?: Maybe<MessageRelaxed>;
|
|
52
|
+
sendMode?: Maybe<SendMode>;
|
|
53
|
+
}): Cell;
|
|
54
|
+
/**
|
|
55
|
+
* Create sender
|
|
56
|
+
*/
|
|
57
|
+
sender(provider: ContractProvider, secretKey: Buffer): Sender;
|
|
58
|
+
}
|
|
@@ -0,0 +1,101 @@
|
|
|
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.WalletContractV1R2 = void 0;
|
|
11
|
+
const core_1 = require("@ton/core");
|
|
12
|
+
const createWalletTransfer_1 = require("./signing/createWalletTransfer");
|
|
13
|
+
class WalletContractV1R2 {
|
|
14
|
+
static create(args) {
|
|
15
|
+
return new WalletContractV1R2(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('te6cckEBAQEAUwAAov8AIN0gggFMl7qXMO1E0NcLH+Ck8mCBAgDXGCDXCx/tRNDTH9P/0VESuvKhIvkBVBBE+RDyovgAAdMfMSDXSpbTB9QC+wDe0aTIyx/L/8ntVNDieG8=', '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.createWalletTransferV1)({
|
|
71
|
+
seqno: args.seqno,
|
|
72
|
+
sendMode,
|
|
73
|
+
secretKey: args.secretKey,
|
|
74
|
+
message: args.message
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* Create sender
|
|
79
|
+
*/
|
|
80
|
+
sender(provider, secretKey) {
|
|
81
|
+
return {
|
|
82
|
+
send: async (args) => {
|
|
83
|
+
let seqno = await this.getSeqno(provider);
|
|
84
|
+
let transfer = this.createTransfer({
|
|
85
|
+
seqno,
|
|
86
|
+
secretKey,
|
|
87
|
+
sendMode: args.sendMode,
|
|
88
|
+
message: (0, core_1.internal)({
|
|
89
|
+
to: args.to,
|
|
90
|
+
value: args.value,
|
|
91
|
+
init: args.init,
|
|
92
|
+
body: args.body,
|
|
93
|
+
bounce: args.bounce
|
|
94
|
+
})
|
|
95
|
+
});
|
|
96
|
+
await this.send(provider, transfer);
|
|
97
|
+
}
|
|
98
|
+
};
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
exports.WalletContractV1R2 = WalletContractV1R2;
|
|
@@ -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 WalletContractV1R2_1 = require("./WalletContractV1R2");
|
|
14
|
+
describe('WalletContractV1R2', () => {
|
|
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(WalletContractV1R2_1.WalletContractV1R2.create({ workchain: 0, publicKey: key.publicKey }));
|
|
20
|
+
let balance = await contract.getBalance();
|
|
21
|
+
// Check parameters
|
|
22
|
+
expect(contract.address.equals(core_1.Address.parse('EQATDkvcCA2fFWbSTHMpGCrjkNGqgEywES15ZS11HHY3UuxK'))).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(WalletContractV1R2_1.WalletContractV1R2.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
|
+
message: (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,58 @@
|
|
|
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 WalletContractV1R3 implements Contract {
|
|
12
|
+
static create(args: {
|
|
13
|
+
workchain: number;
|
|
14
|
+
publicKey: Buffer;
|
|
15
|
+
}): WalletContractV1R3;
|
|
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(executor: ContractProvider, message: Cell): Promise<void>;
|
|
36
|
+
/**
|
|
37
|
+
* Sign and send transfer
|
|
38
|
+
*/
|
|
39
|
+
sendTransfer(provider: ContractProvider, args: {
|
|
40
|
+
seqno: number;
|
|
41
|
+
secretKey: Buffer;
|
|
42
|
+
message?: Maybe<MessageRelaxed>;
|
|
43
|
+
sendMode?: Maybe<SendMode>;
|
|
44
|
+
}): Promise<void>;
|
|
45
|
+
/**
|
|
46
|
+
* Create signed transfer
|
|
47
|
+
*/
|
|
48
|
+
createTransfer(args: {
|
|
49
|
+
seqno: number;
|
|
50
|
+
secretKey: Buffer;
|
|
51
|
+
message?: Maybe<MessageRelaxed>;
|
|
52
|
+
sendMode?: Maybe<SendMode>;
|
|
53
|
+
}): Cell;
|
|
54
|
+
/**
|
|
55
|
+
* Create sender
|
|
56
|
+
*/
|
|
57
|
+
sender(provider: ContractProvider, secretKey: Buffer): Sender;
|
|
58
|
+
}
|
|
@@ -0,0 +1,101 @@
|
|
|
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.WalletContractV1R3 = void 0;
|
|
11
|
+
const core_1 = require("@ton/core");
|
|
12
|
+
const createWalletTransfer_1 = require("./signing/createWalletTransfer");
|
|
13
|
+
class WalletContractV1R3 {
|
|
14
|
+
static create(args) {
|
|
15
|
+
return new WalletContractV1R3(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('te6cckEBAQEAXwAAuv8AIN0gggFMl7ohggEznLqxnHGw7UTQ0x/XC//jBOCk8mCBAgDXGCDXCx/tRNDTH9P/0VESuvKhIvkBVBBE+RDyovgAAdMfMSDXSpbTB9QC+wDe0aTIyx/L/8ntVLW4bkI=', '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(executor, message) {
|
|
53
|
+
await executor.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.createWalletTransferV1)({
|
|
71
|
+
seqno: args.seqno,
|
|
72
|
+
sendMode: sendMode,
|
|
73
|
+
secretKey: args.secretKey,
|
|
74
|
+
message: args.message
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* Create sender
|
|
79
|
+
*/
|
|
80
|
+
sender(provider, secretKey) {
|
|
81
|
+
return {
|
|
82
|
+
send: async (args) => {
|
|
83
|
+
let seqno = await this.getSeqno(provider);
|
|
84
|
+
let transfer = this.createTransfer({
|
|
85
|
+
seqno,
|
|
86
|
+
secretKey,
|
|
87
|
+
sendMode: args.sendMode,
|
|
88
|
+
message: (0, core_1.internal)({
|
|
89
|
+
to: args.to,
|
|
90
|
+
value: args.value,
|
|
91
|
+
init: args.init,
|
|
92
|
+
body: args.body,
|
|
93
|
+
bounce: args.bounce
|
|
94
|
+
})
|
|
95
|
+
});
|
|
96
|
+
await this.send(provider, transfer);
|
|
97
|
+
}
|
|
98
|
+
};
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
exports.WalletContractV1R3 = WalletContractV1R3;
|
|
@@ -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 WalletContractV1R3_1 = require("./WalletContractV1R3");
|
|
14
|
+
describe('WalletContractV1R3', () => {
|
|
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(WalletContractV1R3_1.WalletContractV1R3.create({ workchain: 0, publicKey: key.publicKey }));
|
|
20
|
+
let balance = await contract.getBalance();
|
|
21
|
+
// Check parameters
|
|
22
|
+
expect(contract.address.equals(core_1.Address.parse('EQBRRPBUtgzq5om6O4rtxwPW4hyDxiXYeIko27tvsm97kUw3'))).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(WalletContractV1R3_1.WalletContractV1R3.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
|
+
message: (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
|
+
});
|