@anywalletkit/wallet-ton 0.2.1 → 0.2.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/README.md +11 -0
- package/dist/index.cjs +14 -18
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +4 -4
- package/dist/index.d.ts +4 -4
- package/dist/index.js +15 -19
- package/dist/index.js.map +1 -1
- package/package.json +9 -6
package/README.md
CHANGED
|
@@ -1,11 +1,22 @@
|
|
|
1
1
|
# @anywalletkit/wallet-ton
|
|
2
2
|
|
|
3
|
+
[](https://www.npmjs.com/package/@anywalletkit/wallet-ton)
|
|
4
|
+
|
|
3
5
|
TON accounts at `m/44'/607'/i'` (SLIP-10 ed25519) on Wallet V5R1 — the
|
|
4
6
|
derivation Trust Wallet and Ledger use for a BIP-39 phrase, pinned by
|
|
5
7
|
golden vectors in `@anywalletkit/conformance`. Runtime dependencies: `@ton/core`,
|
|
6
8
|
`@ton/crypto`, `buffer` (no `@ton/ton`: the V5R1 contract and the toncenter
|
|
7
9
|
client are implemented here, byte-for-byte checked against `@ton/ton` in tests).
|
|
8
10
|
|
|
11
|
+
## Install
|
|
12
|
+
|
|
13
|
+
```sh
|
|
14
|
+
npm install @anywalletkit/wallet-ton
|
|
15
|
+
# or: pnpm add @anywalletkit/wallet-ton · yarn add @anywalletkit/wallet-ton
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
On npm: [@anywalletkit/wallet-ton](https://www.npmjs.com/package/@anywalletkit/wallet-ton), published from the [release workflow](https://github.com/ultratestbro/anywalletkit/blob/main/RELEASING.md) with provenance.
|
|
19
|
+
|
|
9
20
|
```ts
|
|
10
21
|
import WalletManagerTon from '@anywalletkit/wallet-ton'
|
|
11
22
|
|
package/dist/index.cjs
CHANGED
|
@@ -1061,12 +1061,12 @@ var WalletAccountTon = class _WalletAccountTon extends WalletAccountReadOnlyTon
|
|
|
1061
1061
|
return sim.fees.total;
|
|
1062
1062
|
}
|
|
1063
1063
|
/** Sign without broadcasting. Returns the external-message BODY as base64 BoC (pass it back to sendTransaction as a Cell). */
|
|
1064
|
-
async signTransaction(tx) {
|
|
1064
|
+
async signTransaction(tx, options = {}) {
|
|
1065
1065
|
if (tx instanceof import_core10.Cell) {
|
|
1066
|
-
await this.preflight(tx, this._config.transactionMaxFee, "transaction");
|
|
1066
|
+
await this.preflight(tx, (0, import_core9.feeLimit)(this._config.transactionMaxFee, options), "transaction");
|
|
1067
1067
|
return tx.toBoc().toString("base64");
|
|
1068
1068
|
}
|
|
1069
|
-
const { body } = await this.prepare(this.toMessages(tx), this._config.transactionMaxFee, "transaction");
|
|
1069
|
+
const { body } = await this.prepare(this.toMessages(tx), (0, import_core9.feeLimit)(this._config.transactionMaxFee, options), "transaction");
|
|
1070
1070
|
return body.toBoc().toString("base64");
|
|
1071
1071
|
}
|
|
1072
1072
|
async broadcast(body) {
|
|
@@ -1076,16 +1076,16 @@ var WalletAccountTon = class _WalletAccountTon extends WalletAccountReadOnlyTon
|
|
|
1076
1076
|
return body.hash().toString("hex");
|
|
1077
1077
|
}
|
|
1078
1078
|
/** Sign and broadcast; `hash` is the body hash (hex) — resolve it with getTransactionReceipt. */
|
|
1079
|
-
async sendTransaction(tx) {
|
|
1079
|
+
async sendTransaction(tx, options = {}) {
|
|
1080
1080
|
this.requireRpc("send transactions");
|
|
1081
|
-
const { body, fee } = tx instanceof import_core10.Cell ? { body: tx, fee: await this.preflight(tx, this._config.transactionMaxFee, "transaction") } : await this.prepare(this.toMessages(tx), this._config.transactionMaxFee, "transaction");
|
|
1081
|
+
const { body, fee } = tx instanceof import_core10.Cell ? { body: tx, fee: await this.preflight(tx, (0, import_core9.feeLimit)(this._config.transactionMaxFee, options), "transaction") } : await this.prepare(this.toMessages(tx), (0, import_core9.feeLimit)(this._config.transactionMaxFee, options), "transaction");
|
|
1082
1082
|
return { hash: await this.broadcast(body), fee };
|
|
1083
1083
|
}
|
|
1084
1084
|
/** TON (no `token`) or jetton transfer. */
|
|
1085
|
-
async transfer(o) {
|
|
1085
|
+
async transfer(o, writeOptions = {}) {
|
|
1086
1086
|
this.requireRpc("transfer tokens");
|
|
1087
1087
|
const message = o.token ? await this.jettonTransferMessage(o) : this.transactionMessage({ to: o.recipient, value: o.amount, ...o.memo !== void 0 ? { body: o.memo } : {} });
|
|
1088
|
-
const { body, fee } = await this.prepare([message], this._config.transferMaxFee, "transfer");
|
|
1088
|
+
const { body, fee } = await this.prepare([message], (0, import_core9.feeLimit)(this._config.transferMaxFee, writeOptions), "transfer");
|
|
1089
1089
|
return { hash: await this.broadcast(body), fee };
|
|
1090
1090
|
}
|
|
1091
1091
|
/** The same wallet as a {@link WalletAccountReadOnlyTon}. */
|
|
@@ -1140,10 +1140,10 @@ var WalletManagerTon = class _WalletManagerTon extends import_core11.WalletManag
|
|
|
1140
1140
|
const full = path.startsWith("m/") ? path : `${TON_BASE_PATH}/${path}`;
|
|
1141
1141
|
const cached = this._accounts.get(full);
|
|
1142
1142
|
if (cached) return cached;
|
|
1143
|
-
|
|
1144
|
-
|
|
1145
|
-
|
|
1146
|
-
|
|
1143
|
+
return this.cachedAccount(full, () => {
|
|
1144
|
+
const signer = import_core11.LocalSigner.leafFromSeed(this.seedBytes(), "ed25519", full);
|
|
1145
|
+
return new WalletAccountTon(signer, signer.publicKey, full, this._config);
|
|
1146
|
+
});
|
|
1147
1147
|
}
|
|
1148
1148
|
/** The one path a non-derivable signer answers to: its own, or 'external'. */
|
|
1149
1149
|
singlePath(signer) {
|
|
@@ -1152,22 +1152,18 @@ var WalletManagerTon = class _WalletManagerTon extends import_core11.WalletManag
|
|
|
1152
1152
|
/** Resolve `path` against an injected signer: the signer itself, or a child when it can derive there. */
|
|
1153
1153
|
async fromSigner(signer, path) {
|
|
1154
1154
|
this.requireSigner("ed25519");
|
|
1155
|
-
let
|
|
1155
|
+
let rel;
|
|
1156
1156
|
let key = this.singlePath(signer);
|
|
1157
1157
|
if ((0, import_core11.isSeedSigner)(signer)) {
|
|
1158
1158
|
if (path === signer.path) key = path;
|
|
1159
1159
|
else if (path.startsWith(`${signer.path}/`)) {
|
|
1160
|
-
|
|
1160
|
+
rel = path.slice(signer.path.length + 1);
|
|
1161
1161
|
key = path;
|
|
1162
1162
|
} else throw new import_core11.SignerError(`This signer yields a single account at path '${signer.path}'; it cannot provide ${path}.`);
|
|
1163
1163
|
} else if (path !== `${TON_BASE_PATH}/0'` && path !== "external") {
|
|
1164
1164
|
throw new import_core11.SignerError(`An external signer yields a single account; ${path} is not derivable from it.`);
|
|
1165
1165
|
}
|
|
1166
|
-
|
|
1167
|
-
if (cached) return cached;
|
|
1168
|
-
const account = new WalletAccountTon(leaf, await leaf.getPublicKey(), key, this._config);
|
|
1169
|
-
this._accounts.set(key, account);
|
|
1170
|
-
return account;
|
|
1166
|
+
return this.signerAccount(key, signer, rel, (leaf, publicKey) => new WalletAccountTon(leaf, publicKey, key, this._config));
|
|
1171
1167
|
}
|
|
1172
1168
|
/** Watch-only account for a public key (hex or bytes) — TON addresses derive from the key, not the other way round. */
|
|
1173
1169
|
getReadOnlyAccount(publicKey) {
|