@pizzaton/ton 0.0.0-stage → 0.1.0
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/CONTRACTS.md +239 -0
- package/README.md +481 -2
- package/dist/airdrop/index.d.mts +18 -0
- package/dist/airdrop/index.mjs +86 -0
- package/dist/connect/errors.d.mts +4 -0
- package/dist/connect/errors.mjs +21 -0
- package/dist/connect/index.d.mts +23 -0
- package/dist/connect/index.mjs +34 -0
- package/dist/contracts/catalog/index.d.mts +361 -0
- package/dist/contracts/catalog/index.mjs +403 -0
- package/dist/contracts/client.d.mts +18 -0
- package/dist/contracts/client.mjs +31 -0
- package/dist/contracts/codecs.d.mts +14 -0
- package/dist/contracts/codecs.mjs +61 -0
- package/dist/contracts/hipo.d.mts +138 -0
- package/dist/contracts/hipo.mjs +198 -0
- package/dist/contracts/index.d.mts +23 -0
- package/dist/contracts/index.mjs +20 -0
- package/dist/contracts/metadata.d.mts +38 -0
- package/dist/contracts/metadata.mjs +50 -0
- package/dist/contracts/module-client.d.mts +20 -0
- package/dist/contracts/module-client.mjs +34 -0
- package/dist/contracts/module.d.mts +8 -0
- package/dist/contracts/module.mjs +11 -0
- package/dist/contracts/wrappers/base.d.mts +18 -0
- package/dist/contracts/wrappers/base.mjs +31 -0
- package/dist/contracts/wrappers/index.d.mts +12 -0
- package/dist/contracts/wrappers/index.mjs +12 -0
- package/dist/contracts/wrappers/jvault-protocols.d.mts +206 -0
- package/dist/contracts/wrappers/jvault-protocols.mjs +432 -0
- package/dist/contracts/wrappers/jvault-support.d.mts +135 -0
- package/dist/contracts/wrappers/jvault-support.mjs +269 -0
- package/dist/contracts/wrappers/jvault.d.mts +123 -0
- package/dist/contracts/wrappers/jvault.mjs +258 -0
- package/dist/contracts/wrappers/memeland.d.mts +253 -0
- package/dist/contracts/wrappers/memeland.mjs +396 -0
- package/dist/contracts/wrappers/multix.d.mts +92 -0
- package/dist/contracts/wrappers/multix.mjs +156 -0
- package/dist/contracts/wrappers/pizzabox.d.mts +66 -0
- package/dist/contracts/wrappers/pizzabox.mjs +105 -0
- package/dist/contracts/wrappers/ton-raffles.d.mts +215 -0
- package/dist/contracts/wrappers/ton-raffles.mjs +398 -0
- package/dist/contracts/wrappers/tonresistor.d.mts +189 -0
- package/dist/contracts/wrappers/tonresistor.mjs +276 -0
- package/dist/core/address.d.mts +25 -0
- package/dist/core/address.mjs +45 -0
- package/dist/core/amount.d.mts +8 -0
- package/dist/core/amount.mjs +34 -0
- package/dist/core/bytes.d.mts +5 -0
- package/dist/core/bytes.mjs +18 -0
- package/dist/core/constants.d.mts +14 -0
- package/dist/core/constants.mjs +15 -0
- package/dist/core/errors.d.mts +9 -0
- package/dist/core/errors.mjs +16 -0
- package/dist/core/http.mjs +39 -0
- package/dist/core/index.d.mts +8 -0
- package/dist/core/index.mjs +8 -0
- package/dist/core/metadata.d.mts +12 -0
- package/dist/core/metadata.mjs +35 -0
- package/dist/core/network.d.mts +24 -0
- package/dist/core/network.mjs +41 -0
- package/dist/emulator/index.d.mts +20 -0
- package/dist/emulator/index.mjs +24 -0
- package/dist/index.d.mts +21 -0
- package/dist/index.mjs +19 -0
- package/dist/indexer/index.d.mts +90 -0
- package/dist/indexer/index.mjs +279 -0
- package/dist/jetton/details.d.mts +27 -0
- package/dist/jetton/details.mjs +116 -0
- package/dist/jetton/index.d.mts +54 -0
- package/dist/jetton/index.mjs +92 -0
- package/dist/jetton/versions.d.mts +12 -0
- package/dist/jetton/versions.mjs +50 -0
- package/dist/nft/collection.d.mts +57 -0
- package/dist/nft/collection.mjs +148 -0
- package/dist/nft/content.d.mts +34 -0
- package/dist/nft/content.mjs +142 -0
- package/dist/nft/index.d.mts +35 -0
- package/dist/nft/index.mjs +51 -0
- package/dist/nft/versions.d.mts +11 -0
- package/dist/nft/versions.mjs +29 -0
- package/dist/provider/index.d.mts +32 -0
- package/dist/provider/index.mjs +1 -0
- package/dist/react/index.d.mts +13 -0
- package/dist/react/index.mjs +48 -0
- package/dist/server/index.d.mts +11 -0
- package/dist/server/index.mjs +55 -0
- package/dist/simulation/index.d.mts +112 -0
- package/dist/simulation/index.mjs +310 -0
- package/dist/transactions/index.d.mts +33 -0
- package/dist/transactions/index.mjs +51 -0
- package/dist/vesting/index.d.mts +12 -0
- package/dist/vesting/index.mjs +25 -0
- package/dist/wallet/index.d.mts +23 -0
- package/dist/wallet/index.mjs +71 -0
- package/package.json +169 -5
package/CONTRACTS.md
ADDED
|
@@ -0,0 +1,239 @@
|
|
|
1
|
+
# @pizzaton/ton contract integrations
|
|
2
|
+
|
|
3
|
+
Protocol-specific TON contract integrations now live inside `@pizzaton/ton`.
|
|
4
|
+
This guide covers the native wrapper, source catalog, and module-client
|
|
5
|
+
subpaths; the separate `@pizzaton/contracts` workspace package has been
|
|
6
|
+
retired.
|
|
7
|
+
|
|
8
|
+
The package owns contract-specific descriptors, versioned adapters, message
|
|
9
|
+
builders, state decoders, and integration fixtures. It does not duplicate TON
|
|
10
|
+
primitives, standard payloads, wallet implementations, or provider behavior.
|
|
11
|
+
|
|
12
|
+
## Scope
|
|
13
|
+
|
|
14
|
+
The package currently provides:
|
|
15
|
+
|
|
16
|
+
- immutable source and audit metadata for official and candidate contracts;
|
|
17
|
+
- a catalog that records exact source commits and security warnings;
|
|
18
|
+
- a typed `ContractModuleClient` for modules implementing `TonContractModule` from `@pizzaton/ton/contracts`;
|
|
19
|
+
- source-pinned native wrappers for Multix DAO and the JVault vesting, airdrop, decentralized launchpad, fixed staking, floating staking, and staking-v2 contract families;
|
|
20
|
+
- source-pinned native wrappers for the supplied Ton-Raffles NFT launchpad, modern and jetton-priced sales, auction, swap, scalable airdrop, off-chain proofs, shopping cart, NFT staking/lending, and PizzaTon jetton-locker contracts;
|
|
21
|
+
- source-pinned native wrappers for Memeland BCL factory/minters/wallets and FeeCollector, plus the TONresistor bonding-curve master, curve, and custom Jetton minter/wallet contracts;
|
|
22
|
+
- Hipo treasury, hGRAM parent, and wallet wrappers with current deposit/unstake message layouts, dynamic fee and wallet getters, and append-only treasury state decoding;
|
|
23
|
+
- the Multix per-sale storage contract, including its buy, TON claim, token claim, veto, and unlock-option encodings;
|
|
24
|
+
- exact message builders, initialization serializers, read-method accessors, and send methods that route through `TonContractClient` from `@pizzaton/ton`;
|
|
25
|
+
- shared registry and client exports from `@pizzaton/ton`.
|
|
26
|
+
|
|
27
|
+
The catalog is not a deployment allowlist. Entries marked `research-only`, `experimental`, or `audit-evidence` must not be used with production funds. A production module will only be added after its exact source, compiler output, code/data hashes, deployment configuration, and audit scope are verified.
|
|
28
|
+
|
|
29
|
+
## Usage
|
|
30
|
+
|
|
31
|
+
```ts
|
|
32
|
+
import {
|
|
33
|
+
CONTRACT_CATALOG,
|
|
34
|
+
ContractModuleClient,
|
|
35
|
+
getContractDescriptor,
|
|
36
|
+
} from "@pizzaton/ton/contracts";
|
|
37
|
+
|
|
38
|
+
const descriptor = getContractDescriptor("tonresistor/bonding-curve", 1);
|
|
39
|
+
if (!descriptor || descriptor.readiness !== "official-reference") {
|
|
40
|
+
throw new Error("This integration is not an official reference adapter");
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
console.log(CONTRACT_CATALOG["official/jetton"].source.commitUrl);
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
## Native wrappers
|
|
47
|
+
|
|
48
|
+
Wrappers are exported from `@pizzaton/ton/contracts/wrappers` and versioned
|
|
49
|
+
by source revision in the catalog. They accept `ContractProvider` and `Sender`
|
|
50
|
+
only at the operation boundary, so the package does not own a wallet session
|
|
51
|
+
or network connection.
|
|
52
|
+
|
|
53
|
+
```ts
|
|
54
|
+
import { Address } from "@ton/core";
|
|
55
|
+
import {
|
|
56
|
+
JVaultStakingPool,
|
|
57
|
+
JVaultStakeWallet,
|
|
58
|
+
MultixDaoContract,
|
|
59
|
+
MultixStorageContract,
|
|
60
|
+
} from "@pizzaton/ton/contracts/wrappers";
|
|
61
|
+
|
|
62
|
+
const pool = JVaultStakingPool.createFromAddress(Address.parse(poolAddress));
|
|
63
|
+
const stakeWallet = JVaultStakeWallet.createFromAddress(
|
|
64
|
+
Address.parse(stakeWalletAddress),
|
|
65
|
+
);
|
|
66
|
+
|
|
67
|
+
const poolState = await pool.getStorageData(provider);
|
|
68
|
+
await stakeWallet.sendUnstakeRequest(
|
|
69
|
+
provider,
|
|
70
|
+
sender,
|
|
71
|
+
100n, // jetton base units
|
|
72
|
+
350_000_000n, // nanoTON attached value
|
|
73
|
+
);
|
|
74
|
+
|
|
75
|
+
const dao = MultixDaoContract.createFromAddress(Address.parse(daoAddress));
|
|
76
|
+
const daoState = await dao.getState(provider);
|
|
77
|
+
const storage = MultixStorageContract.createFromAddress(Address.parse(storageAddress));
|
|
78
|
+
await storage.sendClaimRequestFull(provider, sender, 100_000_000n, contractTonBalance);
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
Memeland and TONresistor use protocol-specific message formats. Their wrappers
|
|
82
|
+
keep the source-defined field order and use explicit value budgets so callers
|
|
83
|
+
can account for deployment/trade gas instead of hiding a network-dependent
|
|
84
|
+
amount:
|
|
85
|
+
|
|
86
|
+
```ts
|
|
87
|
+
import {
|
|
88
|
+
MEMELAND_GAS,
|
|
89
|
+
MemelandBclFactory,
|
|
90
|
+
TonResistorBondingCurve,
|
|
91
|
+
} from "@pizzaton/ton/contracts/wrappers";
|
|
92
|
+
|
|
93
|
+
const factory = MemelandBclFactory.createFromAddress(factoryAddress);
|
|
94
|
+
await factory.sendDeployCoin(provider, sender, deploymentValue, {
|
|
95
|
+
author: authorAddress,
|
|
96
|
+
name: "Pizza",
|
|
97
|
+
symbol: "PIZZA",
|
|
98
|
+
}, {
|
|
99
|
+
deploymentFee: 500_000_000n,
|
|
100
|
+
deploymentGas: MEMELAND_GAS.coinDeployment,
|
|
101
|
+
});
|
|
102
|
+
|
|
103
|
+
const curve = TonResistorBondingCurve.createFromAddress(curveAddress);
|
|
104
|
+
await curve.sendBuy(provider, sender, tonValue, minimumJettonsOut);
|
|
105
|
+
const curveState = await curve.getCurveData(provider);
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
### Hipo liquid staking
|
|
109
|
+
|
|
110
|
+
The Hipo adapter follows the upstream treasury deposit, wallet unstake, and
|
|
111
|
+
getter schemas pinned in the [integration guide](https://github.com/HipoFinance/contract/blob/f7ca3db515b72b0f8e3fe63ffc64ca749e9765e0/docs/integration.md).
|
|
112
|
+
It includes only the published mainnet address helpers; resolve testnet
|
|
113
|
+
addresses from an authoritative deployment source before using another
|
|
114
|
+
network. Fees are dynamic, so read them before each operation and add an
|
|
115
|
+
application-owned gas margin:
|
|
116
|
+
|
|
117
|
+
```ts
|
|
118
|
+
import { HipoParent, HipoTreasury, HipoWallet } from "@pizzaton/ton/contracts/hipo";
|
|
119
|
+
|
|
120
|
+
const treasury = HipoTreasury.createMainnet();
|
|
121
|
+
const depositFees = await treasury.getTreasuryFees(provider);
|
|
122
|
+
await treasury.sendDepositCoins(
|
|
123
|
+
provider,
|
|
124
|
+
sender,
|
|
125
|
+
{ coins: 0n }, // use attached value after Hipo's current fee
|
|
126
|
+
depositFees.depositCoinsFee + depositGasMargin,
|
|
127
|
+
);
|
|
128
|
+
|
|
129
|
+
const parent = HipoParent.createMainnet();
|
|
130
|
+
const walletAddress = await parent.getWalletAddress(provider, ownerAddress);
|
|
131
|
+
const wallet = HipoWallet.createFromAddress(walletAddress);
|
|
132
|
+
const walletFees = await wallet.getWalletFees(provider);
|
|
133
|
+
await wallet.sendUnstakeTokens(
|
|
134
|
+
provider,
|
|
135
|
+
sender,
|
|
136
|
+
{ tokens: hgramAmount, returnExcess: ownerAddress },
|
|
137
|
+
walletFees.unstakeTokensFee + unstakeGasMargin,
|
|
138
|
+
);
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
Hipo's `get_treasury_state` tuple is append-only. The wrapper decodes the
|
|
142
|
+
stable 24-field prefix, the seven fields known from the pinned revision, and
|
|
143
|
+
reports any future tail values through `unknownAppendValueCount`. Protocol
|
|
144
|
+
dictionaries and optional proposed-governor data remain raw cells so callers
|
|
145
|
+
can decode them against the exact upstream version they use. The catalog marks
|
|
146
|
+
Hipo as an official source reference with admin-controlled upgrades; this does
|
|
147
|
+
not verify any deployed code hash or constitute production approval.
|
|
148
|
+
|
|
149
|
+
TONresistor’s custom Jetton messages expose explicit inline/reference forward
|
|
150
|
+
payload variants through `TonResistorForwardPayload`; use the reference form
|
|
151
|
+
for a payload that does not fit safely in the root cell.
|
|
152
|
+
|
|
153
|
+
The complete native family exports are `MemelandBclFactory`,
|
|
154
|
+
`MemelandBclJettonMinter`, `MemelandBclJettonWallet`, `MemelandFeeCollector`,
|
|
155
|
+
`TonResistorBondingCurveMaster`, `TonResistorBondingCurve`,
|
|
156
|
+
`TonResistorJettonMinter`, and `TonResistorJettonWallet`. These are adapters
|
|
157
|
+
for the pinned upstream revisions, not copies of their FunC/Tolk source or a
|
|
158
|
+
replacement for independently verifying the deployed code hash.
|
|
159
|
+
|
|
160
|
+
`Cell` parameters on `MultixDaoContract` and batch airdrop methods represent
|
|
161
|
+
the nested records or dictionaries defined by the upstream Tact/FunC source.
|
|
162
|
+
This keeps the generated ABI authoritative instead of maintaining a second
|
|
163
|
+
incompatible schema in this package. The outer message headers and field order
|
|
164
|
+
are encoded by the wrappers and covered by tests.
|
|
165
|
+
|
|
166
|
+
For JVault, use `JVaultStakingPool`, `JVaultStakeWallet`, `JVaultPoolFactory`,
|
|
167
|
+
`JVaultReferrerWallet`, `JVaultInviteeWallet`, `JVaultVesting`,
|
|
168
|
+
`JVaultVestingFactory`, `JVaultAirdropMain`, `JVaultAirdropUser`, the fixed
|
|
169
|
+
and floating staking wrappers, `JVaultIcoSale`, `JVaultRefWallet`,
|
|
170
|
+
`JVaultLaunchpadSftItem`, and `JVaultSaleAdmin`. Use
|
|
171
|
+
`uint256CoinsDictionary`, `buildJVaultVestingCodeDictionary`, and
|
|
172
|
+
`buildJVaultReferenceDictionary` for the protocol-specific dictionary shapes.
|
|
173
|
+
The auxiliary `JVaultFixedPoolsAdmin`, `JVaultFloatingPoolsAdmin`,
|
|
174
|
+
`JVaultFloatingSharecoms`, and `JVaultSbtSingle` wrappers cover the remaining
|
|
175
|
+
deployed contracts in the supplied JVault repositories.
|
|
176
|
+
The package does not depend on `@jvault/sdk` or any protocol SDK; all builders
|
|
177
|
+
are native and use only `@pizzaton/ton` plus official `@ton/core` primitives.
|
|
178
|
+
|
|
179
|
+
Ton-Raffles wrappers are exported from the root as
|
|
180
|
+
`TonRafflesNftLaunchpadSale`, `TonRafflesModernNftSale`,
|
|
181
|
+
`TonRafflesJettonPricedNftSale`, `TonRafflesNftAuctionV2`,
|
|
182
|
+
`TonRafflesNftSwapV2`, `TonRafflesScalableAirdrop`,
|
|
183
|
+
`TonRafflesAirdropHelper`, `TonRafflesOffchainProofTask`,
|
|
184
|
+
`TonRafflesShoppingCart`, `TonRafflesNftStakingMaster`,
|
|
185
|
+
`TonRafflesNftStakingHelper`, `TonRafflesNftLendingMaster`, and the
|
|
186
|
+
`PizzaTonJettonLocker*` wrappers. The scalable airdrop config requires an
|
|
187
|
+
explicit nonce so derived addresses remain deterministic; do not copy the
|
|
188
|
+
upstream sample's random nonce behavior into deployment tooling.
|
|
189
|
+
|
|
190
|
+
An adapter should implement the shared module contract and use official `@ton/core` types. The client accepts the same `ContractProvider` and `Sender` abstractions used by `@pizzaton/ton`:
|
|
191
|
+
|
|
192
|
+
```ts
|
|
193
|
+
import type { Address, Contract, ContractProvider, Sender } from "@ton/core";
|
|
194
|
+
import type { ContractModule } from "@pizzaton/ton/contracts";
|
|
195
|
+
import { ContractModuleClient } from "@pizzaton/ton/contracts";
|
|
196
|
+
|
|
197
|
+
type Config = { readonly owner: Address };
|
|
198
|
+
type State = { readonly owner: Address };
|
|
199
|
+
type Action = { readonly queryId: bigint };
|
|
200
|
+
|
|
201
|
+
declare const module: ContractModule<Config, State, Action>;
|
|
202
|
+
declare const contract: Contract;
|
|
203
|
+
declare const provider: ContractProvider;
|
|
204
|
+
declare const sender: Sender;
|
|
205
|
+
|
|
206
|
+
const client = new ContractModuleClient(module, { contract, provider, sender });
|
|
207
|
+
const body = client.buildMessage({ queryId: 1n });
|
|
208
|
+
await client.send({ queryId: 1n }, { value: 100_000_000n });
|
|
209
|
+
```
|
|
210
|
+
|
|
211
|
+
The `module` must be a real protocol adapter created with `createContractModule`, and its descriptor must match the pinned source. No placeholder adapter is registered in the catalog.
|
|
212
|
+
|
|
213
|
+
## Package boundaries
|
|
214
|
+
|
|
215
|
+
- Use `@pizzaton/ton/core` for addresses, amounts, metadata, networks, and errors.
|
|
216
|
+
- Use `@pizzaton/ton/contracts` for the generic module contract and provider-backed client.
|
|
217
|
+
- Use `@pizzaton/ton/contracts/wrappers` for the native wrapper catalog, or `@pizzaton/ton/contracts/hipo` for Hipo's focused wrapper surface.
|
|
218
|
+
- Use `@pizzaton/ton/transactions` and `@pizzaton/ton/connect` for wallet transaction intents and TON Connect delivery.
|
|
219
|
+
- Keep product-specific launchpad orchestration outside this package. This
|
|
220
|
+
package owns reusable protocol wrappers; PizzaTon business rules, pricing,
|
|
221
|
+
and revenue routing belong in application/domain packages.
|
|
222
|
+
|
|
223
|
+
## Verification requirements for a production adapter
|
|
224
|
+
|
|
225
|
+
1. Pin the source commit and compiler/toolchain.
|
|
226
|
+
2. Record deployed code and data hashes.
|
|
227
|
+
3. Verify all internal, external, bounced, deployment, upgrade, refund, and timeout paths in an emulator.
|
|
228
|
+
4. Add trace-level tests for insufficient gas, action failure, interleaving, replay, and malformed cells.
|
|
229
|
+
5. Verify standard Jetton/NFT sender authenticity and workchain assumptions.
|
|
230
|
+
6. Match the independent audit to the exact source and compiled artifact.
|
|
231
|
+
7. Register a production adapter only after review approval.
|
|
232
|
+
|
|
233
|
+
## Development
|
|
234
|
+
|
|
235
|
+
```sh
|
|
236
|
+
bun run --filter @pizzaton/ton check-types
|
|
237
|
+
bun run --filter @pizzaton/ton lint
|
|
238
|
+
bun run --filter @pizzaton/ton test
|
|
239
|
+
```
|