@gala-chain/gala-core-sdk 1.1.0-beta.9 → 1.2.0-beta.2
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 +48 -2
- package/dist/bridge.cjs +1 -11
- package/dist/bridge.cjs.map +1 -1
- package/dist/bridge.mjs +1 -11
- package/dist/bridge.mjs.map +1 -1
- package/dist/browser/bridge.js +1 -1
- package/dist/browser/bridge.js.map +1 -1
- package/dist/browser/classes/error_catalog.js +1 -1
- package/dist/browser/classes/error_catalog.js.map +1 -1
- package/dist/browser/classes/error_phase_table.js +1 -1
- package/dist/browser/classes/error_phase_table.js.map +1 -1
- package/dist/browser/index.js +1 -1
- package/dist/browser/reads/gateway_reads.js +1 -1
- package/dist/browser/reads/nft_collections.js +2 -0
- package/dist/browser/reads/nft_collections.js.map +1 -0
- package/dist/browser/reads/nft_fees.js +2 -0
- package/dist/browser/reads/nft_fees.js.map +1 -0
- package/dist/browser/reads/request.js +1 -1
- package/dist/browser/reads/request.js.map +1 -1
- package/dist/browser/utils/dto_operation.js +1 -1
- package/dist/browser/utils/dto_operation.js.map +1 -1
- package/dist/browser/utils/transport.js +1 -1
- package/dist/browser/version.js +1 -1
- package/dist/browser/version.js.map +1 -1
- package/dist/browser/writes/gateway_writes.js +1 -1
- package/dist/browser/writes/gateway_writes.js.map +1 -1
- package/dist/browser/writes/identity.js +1 -1
- package/dist/browser/writes/identity.js.map +1 -1
- package/dist/browser/writes/nft.js +2 -0
- package/dist/browser/writes/nft.js.map +1 -0
- package/dist/browser/writes/nft_fee.js +2 -0
- package/dist/browser/writes/nft_fee.js.map +1 -0
- package/dist/browser/writes/submit.js +1 -1
- package/dist/browser/writes/submit.js.map +1 -1
- package/dist/browser/writes/types.js.map +1 -1
- package/dist/index.cjs +761 -141
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +284 -7
- package/dist/index.d.ts +284 -7
- package/dist/index.mjs +753 -142
- package/dist/index.mjs.map +1 -1
- package/package.json +32 -30
package/README.md
CHANGED
|
@@ -44,7 +44,7 @@ key.fill(0);
|
|
|
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` |
|
|
@@ -231,6 +231,50 @@ await writes.lockTokens({ tokens: [{ tokenClassKey: 'GALA|Unit|none|none', quant
|
|
|
231
231
|
`GATEWAY_WRITE_OUTCOME_UNKNOWN`: the write may have been applied, so check its `uniqueKey` and
|
|
232
232
|
never resend it under a fresh key.
|
|
233
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
|
+
|
|
234
278
|
## Gateway reads
|
|
235
279
|
|
|
236
280
|
```typescript
|
|
@@ -303,7 +347,9 @@ gzipped, before `ethers` and `@solana/*`) are loaded only by an app that imports
|
|
|
303
347
|
|
|
304
348
|
## Status
|
|
305
349
|
|
|
306
|
-
<!-- docs:var version -->1.
|
|
350
|
+
<!-- docs:var version -->1.2.0-beta.2<!-- /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()`;
|
|
307
353
|
rc.5: every Ethereum account a read, write or GalaConnect client sends is
|
|
308
354
|
`eth|<EIP-55>`, the only spelling the gateway accepts, and `galaChainUserRef` is exported; rc.4:
|
|
309
355
|
`bridgeableTokenService` is required). In: signing, signers, transport and the error model (rc.0, from gswap-sdk); the
|
package/dist/bridge.cjs
CHANGED
|
@@ -2272,16 +2272,6 @@ function destinationChainIdOf(value) {
|
|
|
2272
2272
|
/** The method a bridge-out signing failure names. */
|
|
2273
2273
|
const BRIDGE_OUT_METHOD = "RequestTokenBridgeOut";
|
|
2274
2274
|
/**
|
|
2275
|
-
* The contract path whose operation a `RequestTokenBridgeOut` signs: the TOKEN contract's
|
|
2276
|
-
* (`asset-channel_basic-asset_GalaChainToken:RequestTokenBridgeOut`). Verified on stage (2026-11-02): the
|
|
2277
|
-
* chain refuses `...BridgeContract:RequestTokenBridgeOut` ("signed to call ...BridgeContract:RequestTokenBridgeOut,
|
|
2278
|
-
* but the current operation is asset-channel_basic-asset_GalaChainToken:RequestTokenBridgeOut") and accepts this one.
|
|
2279
|
-
* The table's `asset/bridge-contract` entry is right for `BridgeTokenOut` (seen live on stage:
|
|
2280
|
-
* `asset-channel_bridge-chaincode_BridgeContract:BridgeTokenOut`, signed by GalaConnect, not by this SDK), and the grants
|
|
2281
|
-
* embedded in it sign `asset-channel_bridge-chaincode_GalaChainToken:GrantAllowance`, which the table lacks.
|
|
2282
|
-
*/
|
|
2283
|
-
const BRIDGE_OUT_CONTRACT_PATH = "asset/token-contract";
|
|
2284
|
-
/**
|
|
2285
2275
|
* Signs the bridge-out typed data with the app's signer. Whatever the signer throws that is not
|
|
2286
2276
|
* already an SDK error (a declined or locked wallet, a message ethers cannot encode) is
|
|
2287
2277
|
* `SIGNING_FAILED` (`user_rejected` or `failed`, the original as `cause`), and so is a signature
|
|
@@ -2341,7 +2331,7 @@ async function buildBridgeOutPayload(dto, config) {
|
|
|
2341
2331
|
const message = {
|
|
2342
2332
|
destinationChainId,
|
|
2343
2333
|
destinationChainTxFee: sanitizeObject(sanitizedFeeObj),
|
|
2344
|
-
dtoOperation: (0, _gala_chain_gala_core_sdk.dtoOperationOf)(
|
|
2334
|
+
dtoOperation: (0, _gala_chain_gala_core_sdk.dtoOperationOf)("asset/bridge-contract", BRIDGE_OUT_METHOD),
|
|
2345
2335
|
quantity: dto.quantity,
|
|
2346
2336
|
recipient: dto.recipient,
|
|
2347
2337
|
tokenInstance: dto.tokenInstance,
|