@gala-chain/gala-core-sdk 1.1.0-beta.8 → 1.2.0-beta.1

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.
Files changed (41) hide show
  1. package/README.md +52 -5
  2. package/dist/bridge.cjs +1 -1
  3. package/dist/bridge.cjs.map +1 -1
  4. package/dist/bridge.mjs +2 -2
  5. package/dist/bridge.mjs.map +1 -1
  6. package/dist/browser/bridge.js +1 -1
  7. package/dist/browser/bridge.js.map +1 -1
  8. package/dist/browser/classes/error_catalog.js +1 -1
  9. package/dist/browser/classes/error_catalog.js.map +1 -1
  10. package/dist/browser/classes/error_phase_table.js +1 -1
  11. package/dist/browser/classes/error_phase_table.js.map +1 -1
  12. package/dist/browser/index.js +1 -1
  13. package/dist/browser/reads/gateway_reads.js +1 -1
  14. package/dist/browser/reads/nft_collections.js +2 -0
  15. package/dist/browser/reads/nft_collections.js.map +1 -0
  16. package/dist/browser/reads/nft_fees.js +2 -0
  17. package/dist/browser/reads/nft_fees.js.map +1 -0
  18. package/dist/browser/reads/request.js +1 -1
  19. package/dist/browser/reads/request.js.map +1 -1
  20. package/dist/browser/utils/dto_operation.js.map +1 -1
  21. package/dist/browser/utils/pre_send.js +1 -1
  22. package/dist/browser/utils/pre_send.js.map +1 -1
  23. package/dist/browser/utils/transport.js +1 -1
  24. package/dist/browser/version.js +1 -1
  25. package/dist/browser/version.js.map +1 -1
  26. package/dist/browser/writes/gateway_writes.js +1 -1
  27. package/dist/browser/writes/gateway_writes.js.map +1 -1
  28. package/dist/browser/writes/nft.js +2 -0
  29. package/dist/browser/writes/nft.js.map +1 -0
  30. package/dist/browser/writes/nft_fee.js +2 -0
  31. package/dist/browser/writes/nft_fee.js.map +1 -0
  32. package/dist/browser/writes/submit.js +1 -1
  33. package/dist/browser/writes/submit.js.map +1 -1
  34. package/dist/browser/writes/types.js.map +1 -1
  35. package/dist/index.cjs +741 -142
  36. package/dist/index.cjs.map +1 -1
  37. package/dist/index.d.cts +276 -10
  38. package/dist/index.d.ts +276 -10
  39. package/dist/index.mjs +733 -143
  40. package/dist/index.mjs.map +1 -1
  41. package/package.json +32 -30
package/README.md CHANGED
@@ -40,11 +40,11 @@ key.fill(0);
40
40
 
41
41
  | Area | Exports |
42
42
  | --- | --- |
43
- | Signers | `PrivateKeySigner`, `createLazyPrivateKeySigner`, `GalaWalletSigner`, `BrowserWalletSigner`, `signPreSend`, type `GalaChainSigner` |
43
+ | Signers | `PrivateKeySigner`, `createLazyPrivateKeySigner`, `GalaWalletSigner`, `BrowserWalletSigner`, `signPreSend`, `signPreSendFor`, type `GalaChainSigner` |
44
44
  | Signing | `serialize`, `getPayloadToSign`, `signNative`, `signPersonalMessage`, `personalSignPrefixFor`, `fixpointPrefixFor`, `signChainDto*`, `signRawObject`, `generateEIP712Types`, `buildEIP712Payload`, `hashTypedData`, `signTypedDataPayload`; the signed `dtoOperation`: `withDtoOperation`, `dtoOperationOf`, `CHAIN_CONTRACT_OPERATION_PREFIXES`, type `ChainContractPath` |
45
45
  | Transport | `fetchRequestor`, `requestWithTimeout` (`kind: { write: false }` makes a read's timeout and transport failure say `write: false`), `buildRequestHeaders`, `buildQueryString`, `readRetryAfter`, `httpRequestorFromAxios`, `eip1193ProviderFromEthers`, `isFetchTransportFailure`, types `HttpRequestor`, `WireOptions`, `RequestKind` |
46
46
  | Gateway reads | `GatewayReads` (`fetchBalances`, `fetchTokenBalance`, `fetchNftBalances`, `fetchTokenClasses`, `fetchTokenClassesWithSupply`, `fetchTokenClass`, `fetchTokenDetails`, `fetchTokenClassesPage`, `fetchAllTokenClasses`, `fetchNftCollectionAuthorizationsPage`, `fetchAllNftCollectionAuthorizations`, `fetchPublicKey`), `GATEWAY_READ_METHODS`, `GATEWAY_READ_LIMITS`, types `GalaChainTokenBalance`, `GalaChainTokenBalanceSummary`, `GalaChainTokenClass`, `GalaChainTokenDetails`, `GalaChainPage`, `GalaChainPublicKey` |
47
- | Gateway writes | `GatewayWrites` (`transferGala`, `transferToken`, `burnTokens`, `lockTokens`, `unlockTokens`), `galaChainUserRef` (a user reference in the one spelling the gateway accepts), `GATEWAY_WRITE_METHODS`, `GATEWAY_WRITE_BATCH_LIMITS`, `GALA_TOKEN_CLASS_KEY`, types `GatewayWritesOptions`, `GatewayWriteReceipt`, `TokenNameResolver`, `TokenQuantityInput` |
47
+ | Gateway writes | `GatewayWrites` (`transferGala`, `transferToken`, `burnTokens`, `lockTokens`, `unlockTokens`; NFTs: `claimNftCollection`, `createNftCollection`, `mintNft`, `estimateNftFee`), `galaChainUserRef` (a user reference in the one spelling the gateway accepts), `GATEWAY_WRITE_METHODS`, `GATEWAY_WRITE_BATCH_LIMITS`, `GALA_TOKEN_CLASS_KEY`, `NFT_WRITE_METHODS`, `NFT_MINT_LIMIT`, types `GatewayWritesOptions`, `GatewayWriteReceipt`, `WriteReceipt`, `TokenNameResolver`, `TokenQuantityInput`, `NftFeeRequest`, `NftFeeQuote`, `ClaimNftCollectionInput`, `CreateNftCollectionInput`, `MintNftInput` |
48
48
  | Deployments | `GALA_CHAIN_ENVIRONMENTS` (gateway and DEX API of `prod` / `stage`) |
49
49
  | Keys | `compositeKeyOf`, `tryParseTokenClassKey`, `tryParseCompositeKey`, `createUniqueKey`, `assertUniqueKey`, `isValidUniqueKey` |
50
50
  | Wallets | `createWallet` (random, from a private key, or from a 12/24-word mnemonic at `m/44'/60'/0'/0/0`), `validateWalletInput`, `getPublicKeyFromPrivateKey`, `getEthereumAddressFromPrivateKey`, `checksumEthereumAddress`, types `GeneratedWallet`, `PublicKeyResult` |
@@ -215,8 +215,9 @@ await writes.lockTokens({ tokens: [{ tokenClassKey: 'GALA|Unit|none|none', quant
215
215
  signed to call X operation, but the current operation is Y"). The URL of a write and its operation
216
216
  come from one table (`CHAIN_CONTRACT_OPERATION_PREFIXES`), so they cannot disagree. For a call the
217
217
  SDK does not make, use `withDtoOperation(contractPath, method, dto)` (the contract path is the
218
- route's `<channel>/<contract>`, such as `asset/token-contract`) or `signPreSend(signer,
219
- contractPath, method, dto)`, which sets it and signs; a DTO that already names a different
218
+ route's `<channel>/<contract>`, such as `asset/token-contract`) or `signPreSendFor(signer,
219
+ contractPath, method, dto)`, which sets it and signs (`signPreSend(signer, method, dto)` keeps its 1.0.0
220
+ signature and signs the DTO as given); a DTO that already names a different
220
221
  operation is refused as `SIGNING_FAILED`. Never add it after signing: the signature would not
221
222
  cover it. Inside a launchpad bundle the operation is the bundler's `BatchSubmit`
222
223
  (`asset-channel_basic-asset_Launchpad:BatchSubmit`), not the inner DTO's own method: launchpad-sdk sets it.
@@ -230,6 +231,50 @@ await writes.lockTokens({ tokens: [{ tokenClassKey: 'GALA|Unit|none|none', quant
230
231
  `GATEWAY_WRITE_OUTCOME_UNKNOWN`: the write may have been applied, so check its `uniqueKey` and
231
232
  never resend it under a fresh key.
232
233
 
234
+ ### NFT writes
235
+
236
+ On the `writes` above:
237
+
238
+ ```typescript continue
239
+ import { getPublicKeyFromPrivateKey } from '@gala-chain/gala-core-sdk';
240
+
241
+ const claim = await writes.claimNftCollection({ collection: 'MyArt' }); // GrantNftCollectionAuthorization
242
+ await writes.createNftCollection({ // CreateNftCollection
243
+ collection: 'MyArt', category: 'Item', type: 'Sword',
244
+ name: 'Sword', symbol: 'SWD', description: 'A sword', image: 'https://example.com/sword.png',
245
+ maxSupply: '1000', // required: the chain refuses an unbounded NFT supply
246
+ });
247
+ const { tokenInstances } = await writes.mintNft({ // MintTokenWithAllowance (the minter grants itself the allowance)
248
+ collection: 'MyArt', category: 'Item', type: 'Sword', quantity: '2',
249
+ });
250
+ const quote = await writes.estimateNftFee( // the chain's DryRun, nothing is written
251
+ { write: 'mintNft', collection: 'MyArt', category: 'Item', type: 'Sword', quantity: '2' },
252
+ { callerPublicKey: getPublicKeyFromPrivateKey(process.env.GALACHAIN_PRIVATE_KEY!).compressedPublicKey },
253
+ );
254
+ console.log(quote.fee, quote.feeToken); // "1" "GALA" on stage; each environment has its own fees
255
+ ```
256
+
257
+ - Each write takes the checks of every core write (the input is refused before anything is signed
258
+ or sent, `INVALID_NFT_INPUT`; a `uniqueKey` is minted per write unless you pass one, and a timeout
259
+ is `GATEWAY_WRITE_OUTCOME_UNKNOWN`: retry with the SAME `uniqueKey`, never a fresh one).
260
+ - The receipts carry what the chain answered, read and checked, never invented: `collection` and
261
+ `authorizedUsers` of a claim, the `tokenClass` of a create, the `tokenInstances` of a mint (as
262
+ many as asked for, of the class named, none twice; any other answer is `GATEWAY_RESPONSE_INVALID`).
263
+ - `authorizedUser`, `owner` and `authorities` are user references (see the identities above); an
264
+ `eth|` reference is stored by the chain under that account's `client|` alias. `authorities`
265
+ and `owner` default to the writer when omitted.
266
+ - The chain refuses a name another account holds (`COLLECTION_NAME_ALREADY_CLAIMED` for the same name in another
267
+ casing, `USER_NOT_AUTHORIZED_FOR_COLLECTION` for one a different account was granted) but accepted a second claim of a
268
+ name the SAME account already held (stage, 2026-11-04): a claim is not idempotent, so check availability first and
269
+ retry only with the same `uniqueKey` (`UNIQUE_TRANSACTION_CONFLICT` refuses its replay).
270
+ - `mintNft` is `MintTokenWithAllowance` unless `existingAllowance: true` (`MintToken`, which
271
+ spends an allowance the writer already holds).
272
+ - `estimateNftFee` prices the same input with the gateway's DryRun and needs the writer's public
273
+ key (`callerPublicKey`, hex), because a signer is not asked for its own. The fee is the network's
274
+ figure for THIS environment (stage charged 5 GALA for a claim, 5 for a create and 1 for a mint on
275
+ 2026-11-04; the fixed fees of `getNftCollectionClaimFee` are mainnet's), and a write the chain would
276
+ refuse is `GATEWAY_READ_REJECTED`, never a fee.
277
+
233
278
  ## Gateway reads
234
279
 
235
280
  ```typescript
@@ -302,7 +347,9 @@ gzipped, before `ethers` and `@solana/*`) are loaded only by an app that imports
302
347
 
303
348
  ## Status
304
349
 
305
- <!-- docs:var version -->1.1.0-beta.8<!-- /docs:var --> (rc.7: `eth|0x<hex>` is refused as `INVALID_ETH_USER_REF_PREFIX`, not an address form; rc.6: `fetchPublicKey`, MetaMask and Trust Wallet detection, silent `restore()`;
350
+ <!-- docs:var version -->1.2.0-beta.1<!-- /docs:var --> (1.2: NFT collection reads and fee estimates, the NFT writes
351
+ `claimNftCollection`, `createNftCollection` and `mintNft` on `GatewayWrites`, and their DryRun fee quote
352
+ `estimateNftFee`; rc.7: `eth|0x<hex>` is refused as `INVALID_ETH_USER_REF_PREFIX`, not an address form; rc.6: `fetchPublicKey`, MetaMask and Trust Wallet detection, silent `restore()`;
306
353
  rc.5: every Ethereum account a read, write or GalaConnect client sends is
307
354
  `eth|<EIP-55>`, the only spelling the gateway accepts, and `galaChainUserRef` is exported; rc.4:
308
355
  `bridgeableTokenService` is required). In: signing, signers, transport and the error model (rc.0, from gswap-sdk); the
package/dist/bridge.cjs CHANGED
@@ -4841,7 +4841,7 @@ var WrapService = class {
4841
4841
  recipient,
4842
4842
  uniqueKey
4843
4843
  };
4844
- const requestBody = await (0, _gala_chain_gala_core_sdk.signPreSend)(this.signer, WRAP_TOKEN_CONTRACT_PATHS[routing.sourceChannel], "RequestTokenBridgeOut", message);
4844
+ const requestBody = await (0, _gala_chain_gala_core_sdk.signPreSendFor)(this.signer, WRAP_TOKEN_CONTRACT_PATHS[routing.sourceChannel], "RequestTokenBridgeOut", message);
4845
4845
  const response = await this.galaConnectClient.requestWrapOut(routing.sourceChannel, requestBody);
4846
4846
  assertRequestAccepted("RequestTokenBridgeOut", response, uniqueKey);
4847
4847
  return {