@ton-wallet/create 14.0.1 → 14.0.3
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 +6 -3
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const core_1 = require("@ton/core");
|
|
4
|
+
const WalletV5BetaWalletId_1 = require("./WalletV5BetaWalletId");
|
|
5
|
+
describe('Wallet V5Beta wallet id', () => {
|
|
6
|
+
it('Should serialise wallet id', () => {
|
|
7
|
+
const walletId = {
|
|
8
|
+
walletVersion: 'v5',
|
|
9
|
+
networkGlobalId: -239,
|
|
10
|
+
workchain: 0,
|
|
11
|
+
subwalletNumber: 0
|
|
12
|
+
};
|
|
13
|
+
const actual = (0, core_1.beginCell)().store((0, WalletV5BetaWalletId_1.storeWalletIdV5Beta)(walletId)).endCell();
|
|
14
|
+
const expected = (0, core_1.beginCell)()
|
|
15
|
+
.storeInt(walletId.networkGlobalId, 32)
|
|
16
|
+
.storeInt(walletId.workchain, 8)
|
|
17
|
+
.storeUint(0, 8)
|
|
18
|
+
.storeUint(walletId.subwalletNumber, 32)
|
|
19
|
+
.endCell();
|
|
20
|
+
expect(expected.equals(actual)).toBeTruthy();
|
|
21
|
+
});
|
|
22
|
+
it('Should deserialise wallet id', () => {
|
|
23
|
+
const expected = {
|
|
24
|
+
walletVersion: 'v5',
|
|
25
|
+
networkGlobalId: -239,
|
|
26
|
+
workchain: 0,
|
|
27
|
+
subwalletNumber: 0
|
|
28
|
+
};
|
|
29
|
+
const actual = (0, WalletV5BetaWalletId_1.loadWalletIdV5Beta)((0, core_1.beginCell)()
|
|
30
|
+
.storeInt(expected.networkGlobalId, 32)
|
|
31
|
+
.storeInt(expected.workchain, 8)
|
|
32
|
+
.storeUint(0, 8)
|
|
33
|
+
.storeUint(expected.subwalletNumber, 32)
|
|
34
|
+
.endCell().beginParse());
|
|
35
|
+
expect(expected).toEqual(actual);
|
|
36
|
+
});
|
|
37
|
+
it('Should serialise wallet id', () => {
|
|
38
|
+
const walletId = {
|
|
39
|
+
walletVersion: 'v5',
|
|
40
|
+
networkGlobalId: -3,
|
|
41
|
+
workchain: -1,
|
|
42
|
+
subwalletNumber: 1234
|
|
43
|
+
};
|
|
44
|
+
const actual = (0, core_1.beginCell)().store((0, WalletV5BetaWalletId_1.storeWalletIdV5Beta)(walletId)).endCell();
|
|
45
|
+
const expected = (0, core_1.beginCell)()
|
|
46
|
+
.storeInt(walletId.networkGlobalId, 32)
|
|
47
|
+
.storeInt(walletId.workchain, 8)
|
|
48
|
+
.storeUint(0, 8)
|
|
49
|
+
.storeUint(walletId.subwalletNumber, 32)
|
|
50
|
+
.endCell();
|
|
51
|
+
expect(expected.equals(actual)).toBeTruthy();
|
|
52
|
+
});
|
|
53
|
+
it('Should deserialise wallet id', () => {
|
|
54
|
+
const expected = {
|
|
55
|
+
walletVersion: 'v5',
|
|
56
|
+
networkGlobalId: -239,
|
|
57
|
+
workchain: -1,
|
|
58
|
+
subwalletNumber: 1
|
|
59
|
+
};
|
|
60
|
+
const actual = (0, WalletV5BetaWalletId_1.loadWalletIdV5Beta)((0, core_1.beginCell)()
|
|
61
|
+
.storeInt(expected.networkGlobalId, 32)
|
|
62
|
+
.storeInt(expected.workchain, 8)
|
|
63
|
+
.storeUint(0, 8)
|
|
64
|
+
.storeUint(expected.subwalletNumber, 32)
|
|
65
|
+
.endCell().beginParse());
|
|
66
|
+
expect(expected).toEqual(actual);
|
|
67
|
+
});
|
|
68
|
+
});
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { Address, OutActionSendMsg } from '@ton/core';
|
|
2
|
+
export interface OutActionAddExtension {
|
|
3
|
+
type: 'addExtension';
|
|
4
|
+
address: Address;
|
|
5
|
+
}
|
|
6
|
+
export interface OutActionRemoveExtension {
|
|
7
|
+
type: 'removeExtension';
|
|
8
|
+
address: Address;
|
|
9
|
+
}
|
|
10
|
+
export interface OutActionSetIsPublicKeyEnabled {
|
|
11
|
+
type: 'setIsPublicKeyEnabled';
|
|
12
|
+
isEnabled: boolean;
|
|
13
|
+
}
|
|
14
|
+
export type OutActionExtended = OutActionSetIsPublicKeyEnabled | OutActionAddExtension | OutActionRemoveExtension;
|
|
15
|
+
export type OutActionWalletV5 = OutActionExtended | OutActionSendMsg;
|
|
16
|
+
export declare function isOutActionExtended(action: OutActionSendMsg | OutActionExtended): action is OutActionExtended;
|
|
17
|
+
export declare function isOutActionBasic(action: OutActionSendMsg | OutActionExtended): action is OutActionSendMsg;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.isOutActionBasic = exports.isOutActionExtended = void 0;
|
|
4
|
+
function isOutActionExtended(action) {
|
|
5
|
+
return (action.type === 'setIsPublicKeyEnabled' || action.type === 'addExtension' || action.type === 'removeExtension');
|
|
6
|
+
}
|
|
7
|
+
exports.isOutActionExtended = isOutActionExtended;
|
|
8
|
+
function isOutActionBasic(action) {
|
|
9
|
+
return !isOutActionExtended(action);
|
|
10
|
+
}
|
|
11
|
+
exports.isOutActionBasic = isOutActionBasic;
|
|
@@ -0,0 +1,125 @@
|
|
|
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 { SendArgsSignable, SendArgsSigned } from "../signing/singer";
|
|
12
|
+
import { OutActionWalletV5 } from "../v5beta/WalletV5OutActions";
|
|
13
|
+
import { WalletIdV5R1, WalletIdV5R1ClientContext, WalletIdV5R1CustomContext } from "./WalletV5R1WalletId";
|
|
14
|
+
export type WalletV5R1BasicSendArgs = {
|
|
15
|
+
seqno: number;
|
|
16
|
+
timeout?: Maybe<number>;
|
|
17
|
+
};
|
|
18
|
+
export type WalletV5R1SendArgsSinged = WalletV5R1BasicSendArgs & SendArgsSigned & {
|
|
19
|
+
authType?: 'external' | 'internal';
|
|
20
|
+
};
|
|
21
|
+
export type WalletV5R1SendArgsSignable = WalletV5R1BasicSendArgs & SendArgsSignable & {
|
|
22
|
+
authType?: 'external' | 'internal';
|
|
23
|
+
};
|
|
24
|
+
export type Wallet5VR1SendArgsExtensionAuth = WalletV5R1BasicSendArgs & {
|
|
25
|
+
authType: 'extension';
|
|
26
|
+
queryId?: bigint;
|
|
27
|
+
};
|
|
28
|
+
export type WalletV5R1SendArgs = WalletV5R1SendArgsSinged | WalletV5R1SendArgsSignable | Wallet5VR1SendArgsExtensionAuth;
|
|
29
|
+
export type WalletV5R1PackedCell<T> = T extends WalletV5R1SendArgsSignable ? Promise<Cell> : Cell;
|
|
30
|
+
export declare class WalletContractV5R1 implements Contract {
|
|
31
|
+
readonly publicKey: Buffer;
|
|
32
|
+
readonly walletId: WalletIdV5R1<WalletIdV5R1ClientContext | WalletIdV5R1CustomContext>;
|
|
33
|
+
static OpCodes: {
|
|
34
|
+
auth_extension: number;
|
|
35
|
+
auth_signed_external: number;
|
|
36
|
+
auth_signed_internal: number;
|
|
37
|
+
};
|
|
38
|
+
static create<C extends WalletIdV5R1ClientContext | WalletIdV5R1CustomContext>(args: C extends WalletIdV5R1ClientContext ? {
|
|
39
|
+
walletId?: Maybe<WalletIdV5R1<C>>;
|
|
40
|
+
publicKey: Buffer;
|
|
41
|
+
} : {
|
|
42
|
+
workchain?: number;
|
|
43
|
+
publicKey: Buffer;
|
|
44
|
+
walletId?: Maybe<Partial<WalletIdV5R1<C>>>;
|
|
45
|
+
}): WalletContractV5R1;
|
|
46
|
+
readonly address: Address;
|
|
47
|
+
readonly init: {
|
|
48
|
+
data: Cell;
|
|
49
|
+
code: Cell;
|
|
50
|
+
};
|
|
51
|
+
private constructor();
|
|
52
|
+
/**
|
|
53
|
+
* Get Wallet Balance
|
|
54
|
+
*/
|
|
55
|
+
getBalance(provider: ContractProvider): Promise<bigint>;
|
|
56
|
+
/**
|
|
57
|
+
* Get Wallet Seqno
|
|
58
|
+
*/
|
|
59
|
+
getSeqno(provider: ContractProvider): Promise<number>;
|
|
60
|
+
/**
|
|
61
|
+
* Get Wallet Extensions
|
|
62
|
+
*/
|
|
63
|
+
getExtensions(provider: ContractProvider): Promise<Cell | null>;
|
|
64
|
+
/**
|
|
65
|
+
* Get Wallet Extensions
|
|
66
|
+
*/
|
|
67
|
+
getExtensionsArray(provider: ContractProvider): Promise<Address[]>;
|
|
68
|
+
/**
|
|
69
|
+
* Get is secret-key authentication enabled
|
|
70
|
+
*/
|
|
71
|
+
getIsSecretKeyAuthEnabled(provider: ContractProvider): Promise<boolean>;
|
|
72
|
+
/**
|
|
73
|
+
* Send signed transfer
|
|
74
|
+
*/
|
|
75
|
+
send(provider: ContractProvider, message: Cell): Promise<void>;
|
|
76
|
+
/**
|
|
77
|
+
* Sign and send transfer
|
|
78
|
+
*/
|
|
79
|
+
sendTransfer(provider: ContractProvider, args: WalletV5R1SendArgs & {
|
|
80
|
+
messages: MessageRelaxed[];
|
|
81
|
+
sendMode: SendMode;
|
|
82
|
+
}): Promise<void>;
|
|
83
|
+
/**
|
|
84
|
+
* Sign and send add extension request
|
|
85
|
+
*/
|
|
86
|
+
sendAddExtension(provider: ContractProvider, args: WalletV5R1SendArgs & {
|
|
87
|
+
extensionAddress: Address;
|
|
88
|
+
}): Promise<void>;
|
|
89
|
+
/**
|
|
90
|
+
* Sign and send remove extension request
|
|
91
|
+
*/
|
|
92
|
+
sendRemoveExtension(provider: ContractProvider, args: WalletV5R1SendArgs & {
|
|
93
|
+
extensionAddress: Address;
|
|
94
|
+
}): Promise<void>;
|
|
95
|
+
private createActions;
|
|
96
|
+
/**
|
|
97
|
+
* Create signed transfer
|
|
98
|
+
*/
|
|
99
|
+
createTransfer<T extends WalletV5R1SendArgs>(args: T & {
|
|
100
|
+
messages: MessageRelaxed[];
|
|
101
|
+
sendMode: SendMode;
|
|
102
|
+
}): WalletV5R1PackedCell<T>;
|
|
103
|
+
/**
|
|
104
|
+
* Create signed add extension request
|
|
105
|
+
*/
|
|
106
|
+
createAddExtension<T extends WalletV5R1SendArgs>(args: T & {
|
|
107
|
+
extensionAddress: Address;
|
|
108
|
+
}): WalletV5R1PackedCell<T>;
|
|
109
|
+
/**
|
|
110
|
+
* Create signed remove extension request
|
|
111
|
+
*/
|
|
112
|
+
createRemoveExtension<T extends WalletV5R1SendArgs>(args: T & {
|
|
113
|
+
extensionAddress: Address;
|
|
114
|
+
}): WalletV5R1PackedCell<T>;
|
|
115
|
+
/**
|
|
116
|
+
* Create signed request or extension auth request
|
|
117
|
+
*/
|
|
118
|
+
createRequest<T extends WalletV5R1SendArgs>(args: T & {
|
|
119
|
+
actions: OutActionWalletV5[];
|
|
120
|
+
}): WalletV5R1PackedCell<T>;
|
|
121
|
+
/**
|
|
122
|
+
* Create sender
|
|
123
|
+
*/
|
|
124
|
+
sender(provider: ContractProvider, secretKey: Buffer): Sender;
|
|
125
|
+
}
|
|
@@ -0,0 +1,207 @@
|
|
|
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.WalletContractV5R1 = void 0;
|
|
11
|
+
const core_1 = require("@ton/core");
|
|
12
|
+
const createWalletTransfer_1 = require("../signing/createWalletTransfer");
|
|
13
|
+
const WalletV5R1WalletId_1 = require("./WalletV5R1WalletId");
|
|
14
|
+
class WalletContractV5R1 {
|
|
15
|
+
static create(args) {
|
|
16
|
+
let workchain = 0;
|
|
17
|
+
if ('workchain' in args && args.workchain != undefined) {
|
|
18
|
+
workchain = args.workchain;
|
|
19
|
+
}
|
|
20
|
+
if (args.walletId?.context && (0, WalletV5R1WalletId_1.isWalletIdV5R1ClientContext)(args.walletId.context) && args.walletId.context.workchain != undefined) {
|
|
21
|
+
workchain = args.walletId.context.workchain;
|
|
22
|
+
}
|
|
23
|
+
return new WalletContractV5R1(workchain, args.publicKey, {
|
|
24
|
+
networkGlobalId: args.walletId?.networkGlobalId ?? -239,
|
|
25
|
+
context: args.walletId?.context ?? {
|
|
26
|
+
workchain: 0,
|
|
27
|
+
walletVersion: 'v5r1',
|
|
28
|
+
subwalletNumber: 0
|
|
29
|
+
}
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
constructor(workchain, publicKey, walletId) {
|
|
33
|
+
this.publicKey = publicKey;
|
|
34
|
+
this.walletId = walletId;
|
|
35
|
+
this.walletId = walletId;
|
|
36
|
+
// https://github.com/ton-blockchain/wallet-contract-v5/blob/4fab977f4fae3a37c1aac216ed2b7e611a9bc2af/build/wallet_v5.compiled.json
|
|
37
|
+
let code = core_1.Cell.fromBoc(Buffer.from('b5ee9c7241021401000281000114ff00f4a413f4bcf2c80b01020120020d020148030402dcd020d749c120915b8f6320d70b1f2082106578746ebd21821073696e74bdb0925f03e082106578746eba8eb48020d72101d074d721fa4030fa44f828fa443058bd915be0ed44d0810141d721f4058307f40e6fa1319130e18040d721707fdb3ce03120d749810280b99130e070e2100f020120050c020120060902016e07080019adce76a2684020eb90eb85ffc00019af1df6a2684010eb90eb858fc00201480a0b0017b325fb51341c75c875c2c7e00011b262fb513435c280200019be5f0f6a2684080a0eb90fa02c0102f20e011e20d70b1f82107369676ebaf2e08a7f0f01e68ef0eda2edfb218308d722028308d723208020d721d31fd31fd31fed44d0d200d31f20d31fd3ffd70a000af90140ccf9109a28945f0adb31e1f2c087df02b35007b0f2d0845125baf2e0855036baf2e086f823bbf2d0882292f800de01a47fc8ca00cb1f01cf16c9ed542092f80fde70db3cd81003f6eda2edfb02f404216e926c218e4c0221d73930709421c700b38e2d01d72820761e436c20d749c008f2e09320d74ac002f2e09320d71d06c712c2005230b0f2d089d74cd7393001a4e86c128407bbf2e093d74ac000f2e093ed55e2d20001c000915be0ebd72c08142091709601d72c081c12e25210b1e30f20d74a111213009601fa4001fa44f828fa443058baf2e091ed44d0810141d718f405049d7fc8ca0040048307f453f2e08b8e14038307f45bf2e08c22d70a00216e01b3b0f2d090e2c85003cf1612f400c9ed54007230d72c08248e2d21f2e092d200ed44d0d2005113baf2d08f54503091319c01810140d721d70a00f2e08ee2c8ca0058cf16c9ed5493f2c08de20010935bdb31e1d74cd0b4d6c35e', 'hex'))[0];
|
|
38
|
+
let data = (0, core_1.beginCell)()
|
|
39
|
+
.storeUint(1, 1) // is signature auth allowed
|
|
40
|
+
.storeUint(0, 32) // Seqno
|
|
41
|
+
.store((0, WalletV5R1WalletId_1.storeWalletIdV5R1)(this.walletId))
|
|
42
|
+
.storeBuffer(this.publicKey, 32)
|
|
43
|
+
.storeBit(0) // Empty plugins dict
|
|
44
|
+
.endCell();
|
|
45
|
+
this.init = { code, data };
|
|
46
|
+
this.address = (0, core_1.contractAddress)(workchain, { code, data });
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Get Wallet Balance
|
|
50
|
+
*/
|
|
51
|
+
async getBalance(provider) {
|
|
52
|
+
let state = await provider.getState();
|
|
53
|
+
return state.balance;
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Get Wallet Seqno
|
|
57
|
+
*/
|
|
58
|
+
async getSeqno(provider) {
|
|
59
|
+
let state = await provider.getState();
|
|
60
|
+
if (state.state.type === 'active') {
|
|
61
|
+
let res = await provider.get('seqno', []);
|
|
62
|
+
return res.stack.readNumber();
|
|
63
|
+
}
|
|
64
|
+
else {
|
|
65
|
+
return 0;
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Get Wallet Extensions
|
|
70
|
+
*/
|
|
71
|
+
async getExtensions(provider) {
|
|
72
|
+
let state = await provider.getState();
|
|
73
|
+
if (state.state.type === 'active') {
|
|
74
|
+
const result = await provider.get('get_extensions', []);
|
|
75
|
+
return result.stack.readCellOpt();
|
|
76
|
+
}
|
|
77
|
+
else {
|
|
78
|
+
return null;
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* Get Wallet Extensions
|
|
83
|
+
*/
|
|
84
|
+
async getExtensionsArray(provider) {
|
|
85
|
+
const extensions = await this.getExtensions(provider);
|
|
86
|
+
if (!extensions) {
|
|
87
|
+
return [];
|
|
88
|
+
}
|
|
89
|
+
const dict = core_1.Dictionary.loadDirect(core_1.Dictionary.Keys.BigUint(256), core_1.Dictionary.Values.BigInt(1), extensions);
|
|
90
|
+
return dict.keys().map(addressHex => {
|
|
91
|
+
const wc = this.address.workChain;
|
|
92
|
+
return core_1.Address.parseRaw(`${wc}:${addressHex.toString(16).padStart(64, '0')}`);
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* Get is secret-key authentication enabled
|
|
97
|
+
*/
|
|
98
|
+
async getIsSecretKeyAuthEnabled(provider) {
|
|
99
|
+
let res = await provider.get('is_signature_allowed', []);
|
|
100
|
+
return res.stack.readBoolean();
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* Send signed transfer
|
|
104
|
+
*/
|
|
105
|
+
async send(provider, message) {
|
|
106
|
+
await provider.external(message);
|
|
107
|
+
}
|
|
108
|
+
/**
|
|
109
|
+
* Sign and send transfer
|
|
110
|
+
*/
|
|
111
|
+
async sendTransfer(provider, args) {
|
|
112
|
+
const transfer = await this.createTransfer(args);
|
|
113
|
+
await this.send(provider, transfer);
|
|
114
|
+
}
|
|
115
|
+
/**
|
|
116
|
+
* Sign and send add extension request
|
|
117
|
+
*/
|
|
118
|
+
async sendAddExtension(provider, args) {
|
|
119
|
+
const request = await this.createAddExtension(args);
|
|
120
|
+
await this.send(provider, request);
|
|
121
|
+
}
|
|
122
|
+
/**
|
|
123
|
+
* Sign and send remove extension request
|
|
124
|
+
*/
|
|
125
|
+
async sendRemoveExtension(provider, args) {
|
|
126
|
+
const request = await this.createRemoveExtension(args);
|
|
127
|
+
await this.send(provider, request);
|
|
128
|
+
}
|
|
129
|
+
createActions(args) {
|
|
130
|
+
const actions = args.messages.map(message => ({ type: 'sendMsg', mode: args.sendMode, outMsg: message }));
|
|
131
|
+
return actions;
|
|
132
|
+
}
|
|
133
|
+
/**
|
|
134
|
+
* Create signed transfer
|
|
135
|
+
*/
|
|
136
|
+
createTransfer(args) {
|
|
137
|
+
return this.createRequest({
|
|
138
|
+
actions: this.createActions({ messages: args.messages, sendMode: args.sendMode }),
|
|
139
|
+
...args
|
|
140
|
+
});
|
|
141
|
+
}
|
|
142
|
+
/**
|
|
143
|
+
* Create signed add extension request
|
|
144
|
+
*/
|
|
145
|
+
createAddExtension(args) {
|
|
146
|
+
return this.createRequest({
|
|
147
|
+
actions: [{
|
|
148
|
+
type: 'addExtension',
|
|
149
|
+
address: args.extensionAddress
|
|
150
|
+
}],
|
|
151
|
+
...args
|
|
152
|
+
});
|
|
153
|
+
}
|
|
154
|
+
/**
|
|
155
|
+
* Create signed remove extension request
|
|
156
|
+
*/
|
|
157
|
+
createRemoveExtension(args) {
|
|
158
|
+
return this.createRequest({
|
|
159
|
+
actions: [{
|
|
160
|
+
type: 'removeExtension',
|
|
161
|
+
address: args.extensionAddress
|
|
162
|
+
}],
|
|
163
|
+
...args
|
|
164
|
+
});
|
|
165
|
+
}
|
|
166
|
+
/**
|
|
167
|
+
* Create signed request or extension auth request
|
|
168
|
+
*/
|
|
169
|
+
createRequest(args) {
|
|
170
|
+
if (args.authType === 'extension') {
|
|
171
|
+
return (0, createWalletTransfer_1.createWalletTransferV5R1)(args);
|
|
172
|
+
}
|
|
173
|
+
return (0, createWalletTransfer_1.createWalletTransferV5R1)({
|
|
174
|
+
...args,
|
|
175
|
+
walletId: (0, WalletV5R1WalletId_1.storeWalletIdV5R1)(this.walletId)
|
|
176
|
+
});
|
|
177
|
+
}
|
|
178
|
+
/**
|
|
179
|
+
* Create sender
|
|
180
|
+
*/
|
|
181
|
+
sender(provider, secretKey) {
|
|
182
|
+
return {
|
|
183
|
+
send: async (args) => {
|
|
184
|
+
let seqno = await this.getSeqno(provider);
|
|
185
|
+
let transfer = this.createTransfer({
|
|
186
|
+
seqno,
|
|
187
|
+
secretKey,
|
|
188
|
+
sendMode: args.sendMode ?? core_1.SendMode.PAY_GAS_SEPARATELY + core_1.SendMode.IGNORE_ERRORS,
|
|
189
|
+
messages: [(0, core_1.internal)({
|
|
190
|
+
to: args.to,
|
|
191
|
+
value: args.value,
|
|
192
|
+
init: args.init,
|
|
193
|
+
body: args.body,
|
|
194
|
+
bounce: args.bounce
|
|
195
|
+
})]
|
|
196
|
+
});
|
|
197
|
+
await this.send(provider, transfer);
|
|
198
|
+
}
|
|
199
|
+
};
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
exports.WalletContractV5R1 = WalletContractV5R1;
|
|
203
|
+
WalletContractV5R1.OpCodes = {
|
|
204
|
+
auth_extension: 0x6578746e,
|
|
205
|
+
auth_signed_external: 0x7369676e,
|
|
206
|
+
auth_signed_internal: 0x73696e74
|
|
207
|
+
};
|