@gala-chain/gala-core-sdk 0.0.0-stage → 1.0.0-rc.5

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 (118) hide show
  1. package/LICENSE.txt +201 -0
  2. package/README.md +266 -2
  3. package/dist/bridge.cjs +4902 -0
  4. package/dist/bridge.cjs.map +1 -0
  5. package/dist/bridge.d.cts +2712 -0
  6. package/dist/bridge.d.ts +2712 -0
  7. package/dist/bridge.mjs +4817 -0
  8. package/dist/bridge.mjs.map +1 -0
  9. package/dist/browser/_virtual/_@oxc-project_runtime@0.153.0/helpers/esm/defineProperty.js +1 -0
  10. package/dist/browser/_virtual/_@oxc-project_runtime@0.153.0/helpers/esm/toPrimitive.js +1 -0
  11. package/dist/browser/_virtual/_@oxc-project_runtime@0.153.0/helpers/esm/toPropertyKey.js +1 -0
  12. package/dist/browser/_virtual/_@oxc-project_runtime@0.153.0/helpers/esm/typeof.js +1 -0
  13. package/dist/browser/bridge.js +2 -0
  14. package/dist/browser/bridge.js.map +1 -0
  15. package/dist/browser/classes/error_catalog.js +2 -0
  16. package/dist/browser/classes/error_catalog.js.map +1 -0
  17. package/dist/browser/classes/error_phase_table.js +2 -0
  18. package/dist/browser/classes/error_phase_table.js.map +1 -0
  19. package/dist/browser/classes/error_phases.js +2 -0
  20. package/dist/browser/classes/error_phases.js.map +1 -0
  21. package/dist/browser/classes/gala_sdk_error.js +2 -0
  22. package/dist/browser/classes/gala_sdk_error.js.map +1 -0
  23. package/dist/browser/classes/signers.js +2 -0
  24. package/dist/browser/classes/signers.js.map +1 -0
  25. package/dist/browser/config/environments.js +2 -0
  26. package/dist/browser/config/environments.js.map +1 -0
  27. package/dist/browser/index.js +1 -0
  28. package/dist/browser/providers.js +2 -0
  29. package/dist/browser/providers.js.map +1 -0
  30. package/dist/browser/react.js +2 -0
  31. package/dist/browser/react.js.map +1 -0
  32. package/dist/browser/reads/gateway_reads.js +2 -0
  33. package/dist/browser/reads/gateway_reads.js.map +1 -0
  34. package/dist/browser/reads/parse.js +2 -0
  35. package/dist/browser/reads/parse.js.map +1 -0
  36. package/dist/browser/reads/request.js +2 -0
  37. package/dist/browser/reads/request.js.map +1 -0
  38. package/dist/browser/reads/types.js +2 -0
  39. package/dist/browser/reads/types.js.map +1 -0
  40. package/dist/browser/utils/axios_requestor.js +2 -0
  41. package/dist/browser/utils/axios_requestor.js.map +1 -0
  42. package/dist/browser/utils/chain_dto_signing.js +3 -0
  43. package/dist/browser/utils/chain_dto_signing.js.map +1 -0
  44. package/dist/browser/utils/class_key.js +2 -0
  45. package/dist/browser/utils/class_key.js.map +1 -0
  46. package/dist/browser/utils/eip712.js +4 -0
  47. package/dist/browser/utils/eip712.js.map +1 -0
  48. package/dist/browser/utils/error_brand.js +2 -0
  49. package/dist/browser/utils/error_brand.js.map +1 -0
  50. package/dist/browser/utils/eth_address.js +2 -0
  51. package/dist/browser/utils/eth_address.js.map +1 -0
  52. package/dist/browser/utils/ethers_provider.js +2 -0
  53. package/dist/browser/utils/ethers_provider.js.map +1 -0
  54. package/dist/browser/utils/failure_outcomes.js +2 -0
  55. package/dist/browser/utils/failure_outcomes.js.map +1 -0
  56. package/dist/browser/utils/failure_view.js +2 -0
  57. package/dist/browser/utils/failure_view.js.map +1 -0
  58. package/dist/browser/utils/fetch_failure.js +2 -0
  59. package/dist/browser/utils/fetch_failure.js.map +1 -0
  60. package/dist/browser/utils/pre_send.js +2 -0
  61. package/dist/browser/utils/pre_send.js.map +1 -0
  62. package/dist/browser/utils/signing.js +3 -0
  63. package/dist/browser/utils/signing.js.map +1 -0
  64. package/dist/browser/utils/transport.js +2 -0
  65. package/dist/browser/utils/transport.js.map +1 -0
  66. package/dist/browser/utils/typed_data.js +2 -0
  67. package/dist/browser/utils/typed_data.js.map +1 -0
  68. package/dist/browser/utils/unique_key.js +2 -0
  69. package/dist/browser/utils/unique_key.js.map +1 -0
  70. package/dist/browser/utils/unique_key_syntax.js +2 -0
  71. package/dist/browser/utils/unique_key_syntax.js.map +1 -0
  72. package/dist/browser/utils/wallet_keys.js +2 -0
  73. package/dist/browser/utils/wallet_keys.js.map +1 -0
  74. package/dist/browser/utils/wallet_rejection.js +2 -0
  75. package/dist/browser/utils/wallet_rejection.js.map +1 -0
  76. package/dist/browser/version.js +2 -0
  77. package/dist/browser/version.js.map +1 -0
  78. package/dist/browser/wallet.js +2 -0
  79. package/dist/browser/wallet.js.map +1 -0
  80. package/dist/browser/writes/gateway_writes.js +2 -0
  81. package/dist/browser/writes/gateway_writes.js.map +1 -0
  82. package/dist/browser/writes/identity.js +2 -0
  83. package/dist/browser/writes/identity.js.map +1 -0
  84. package/dist/browser/writes/lock.js +2 -0
  85. package/dist/browser/writes/lock.js.map +1 -0
  86. package/dist/browser/writes/submit.js +2 -0
  87. package/dist/browser/writes/submit.js.map +1 -0
  88. package/dist/browser/writes/token_ref.js +2 -0
  89. package/dist/browser/writes/token_ref.js.map +1 -0
  90. package/dist/browser/writes/transfer.js +2 -0
  91. package/dist/browser/writes/transfer.js.map +1 -0
  92. package/dist/browser/writes/types.js +2 -0
  93. package/dist/browser/writes/types.js.map +1 -0
  94. package/dist/index.cjs +4769 -0
  95. package/dist/index.cjs.map +1 -0
  96. package/dist/index.d.cts +3012 -0
  97. package/dist/index.d.ts +3012 -0
  98. package/dist/index.mjs +4634 -0
  99. package/dist/index.mjs.map +1 -0
  100. package/dist/providers.cjs +945 -0
  101. package/dist/providers.cjs.map +1 -0
  102. package/dist/providers.d.cts +523 -0
  103. package/dist/providers.d.ts +523 -0
  104. package/dist/providers.mjs +928 -0
  105. package/dist/providers.mjs.map +1 -0
  106. package/dist/react.cjs +382 -0
  107. package/dist/react.cjs.map +1 -0
  108. package/dist/react.d.cts +145 -0
  109. package/dist/react.d.ts +145 -0
  110. package/dist/react.mjs +372 -0
  111. package/dist/react.mjs.map +1 -0
  112. package/dist/wallet.cjs +160 -0
  113. package/dist/wallet.cjs.map +1 -0
  114. package/dist/wallet.d.cts +74 -0
  115. package/dist/wallet.d.ts +74 -0
  116. package/dist/wallet.mjs +157 -0
  117. package/dist/wallet.mjs.map +1 -0
  118. package/package.json +181 -3
package/LICENSE.txt ADDED
@@ -0,0 +1,201 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright (c) Gala Games Inc.
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
package/README.md CHANGED
@@ -1,3 +1,267 @@
1
- # Temporary Holding Version
1
+ # GalaChain core SDK
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ `@gala-chain/gala-core-sdk` is the layer every GalaChain product SDK and app shares: signing
4
+ (native, personal-sign, EIP-712 and arbitrary typed data), the signers (private key, lazy private
5
+ key, Gala Wallet, EIP-1193 browser wallets), the gateway transport (`fetch` requestor with
6
+ timeouts, wire options, axios and ethers adapters), the gateway token reads (balances and holds,
7
+ token classes, NFT collection authorizations) and writes (transfer, burn, lock, unlock), token
8
+ class keys and write `uniqueKey`s, and the shared error model (`GalaSDKError`, its
9
+ catalog, the failure view). It speaks to the GalaChain
10
+ gateway generically; product backends (dex-backend, launchpad-backend) have their own SDKs
11
+ (`@gala-chain/gswap-sdk`, `@gala-chain/launchpad-sdk`) that build on it.
12
+
13
+ ## Install
14
+
15
+ ```bash
16
+ npm install @gala-chain/gala-core-sdk@next
17
+ ```
18
+
19
+ 1.0 is a release candidate, published under the `next` dist-tag: install `@next`, and pin the exact
20
+ version in an app build. A product SDK takes core as a **peer dependency**: install it next to the
21
+ product SDK, once.
22
+
23
+ ## Quick start
24
+
25
+ ```typescript
26
+ import { PrivateKeySigner, serialize, signNative, normalizePrivateKey } from '@gala-chain/gala-core-sdk';
27
+
28
+ const signer = new PrivateKeySigner(process.env.GALACHAIN_PRIVATE_KEY!);
29
+ const signed = await signer.signObject('TransferToken', { quantity: '1', uniqueKey: 'k-1' });
30
+
31
+ // The primitives the signer is built on, byte-identical to @gala-chain/api:
32
+ const key = normalizePrivateKey(process.env.GALACHAIN_PRIVATE_KEY!);
33
+ console.log(serialize({ b: 1, a: 2 }), signNative(key, { a: 1 }));
34
+ key.fill(0);
35
+ ```
36
+
37
+ ## What is in it
38
+
39
+ | Area | Exports |
40
+ | --- | --- |
41
+ | Signers | `PrivateKeySigner`, `createLazyPrivateKeySigner`, `GalaWalletSigner`, `BrowserWalletSigner`, `signPreSend`, type `GalaChainSigner` |
42
+ | Signing | `serialize`, `getPayloadToSign`, `signNative`, `signPersonalMessage`, `personalSignPrefixFor`, `fixpointPrefixFor`, `signChainDto*`, `signRawObject`, `generateEIP712Types`, `buildEIP712Payload`, `hashTypedData`, `signTypedDataPayload` |
43
+ | 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` |
44
+ | 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` |
45
+ | Gateway reads | `GatewayReads` (`fetchBalances`, `fetchTokenBalance`, `fetchNftBalances`, `fetchTokenClasses`, `fetchTokenClassesWithSupply`, `fetchTokenClass`, `fetchTokenDetails`, `fetchTokenClassesPage`, `fetchAllTokenClasses`, `fetchNftCollectionAuthorizationsPage`, `fetchAllNftCollectionAuthorizations`), `GATEWAY_READ_METHODS`, `GATEWAY_READ_LIMITS`, types `GalaChainTokenBalance`, `GalaChainTokenBalanceSummary`, `GalaChainTokenClass`, `GalaChainTokenDetails`, `GalaChainPage` |
46
+ | Deployments | `GALA_CHAIN_ENVIRONMENTS` (gateway and DEX API of `prod` / `stage`) |
47
+ | Keys | `compositeKeyOf`, `tryParseTokenClassKey`, `tryParseCompositeKey`, `createUniqueKey`, `assertUniqueKey`, `isValidUniqueKey` |
48
+ | 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` |
49
+ | Errors | `GalaSDKError`, `isGalaError`, `GALA_ERROR_CATALOG`, `galaErrorTemplates`, `GALA_ERROR_PHASE_BY_CODE`, `toFailureView`, `isWriteView`, `FAILURE_OUTCOMES` |
50
+ | Wallet helpers (`./wallet`) | `isWalletUserRejection`, `walletDeclineCode`, `isGalaErrorLike` |
51
+ | Wallet providers (`./providers`) | `PrivateKeyProvider`, `ExternalWalletProvider`, `GalaWalletProvider`, `detectWallets`, `subscribeToWalletChanges`, `getWalletByRdns`, `isWalletAvailable`, `hasAnyWallet`, `getInjectedEip1193Provider`, `KNOWN_WALLET_RDNS`, `createWalletProvider`, `createProviderFromEip1193`, `ensureConnected`, `getPrivateKeyIfAvailable`, `isPrivateKeyProvider`, `isExternalProvider`, `isEip1193Provider`, type `WalletProvider` |
52
+ | React (`./react`) | `WalletProvider` (context component), `WalletContext`, `useWallet`, `useWalletContext`, `useWalletConnection`, `useWalletDetection`, `useWalletAddress`, `useGalaAddress`, `useWalletProvider`, `useIsWalletConnected` |
53
+ | Bridge (`./bridge`) | `BridgeService` (bridge out to and in from Ethereum and Solana, fees, status, external balances), `EthereumBridgeStrategy`, `SolanaBridgeStrategy`, `BaseBridgeStrategy`, `GalaConnectClient`, `BridgeableTokenService`, `WrappableTokenService`, `WrapService` (channel wrap / unwrap), `createSolanaWallet`, `buildBridgeOutPayload` (the signed bridge-out request), the bridge constants and token tables, the bridge types, `RateLimiter`, the token amount helpers (`toBaseUnits`, `fromBaseUnits`, `formatTokenAmount`, `compareAmounts`) |
54
+
55
+ ## Subpaths
56
+
57
+ Each subpath is its own build: it loads the root (and `./react` the providers) through the package,
58
+ never a copy, so an app has one `GalaSDKError` class, one signer set and one set of provider classes
59
+ (checked on the packed tarball by `pnpm run check:pack`, and on the source by
60
+ `tests/subpath_isolation.test.ts`). The root never loads a subpath.
61
+
62
+ | Entry | What it is for | Loads (besides the root) | Peer it needs |
63
+ | --- | --- | --- | --- |
64
+ | `@gala-chain/gala-core-sdk` | Signing, signers, transport, gateway reads and writes, keys, wallets, errors | `@noble/*`, `@scure/bip32`, `@scure/bip39`, `bignumber.js` | none |
65
+ | `@gala-chain/gala-core-sdk/wallet` | The dependency-free wallet helpers (an app shell) | nothing (not even the root) | none |
66
+ | `@gala-chain/gala-core-sdk/providers` | One `WalletProvider` per wallet kind, EIP-6963 detection | `@noble/hashes` | none |
67
+ | `@gala-chain/gala-core-sdk/react` | The wallet context and hooks | `./providers` | `react` (optional peer, 16.8 to 19; `react-dom` is not needed) |
68
+ | `@gala-chain/gala-core-sdk/bridge` | Bridging GalaChain to and from Ethereum and Solana, channel wrap / unwrap, the bridgeable and wrappable token lists | `ethers`, `@solana/web3.js`, `@solana/spl-token`, `@scure/base`, `bignumber.js` | `ethers` 6, `@solana/web3.js` 1.99+, `@solana/spl-token` 0.4.15+ (optional peers: install them when you import `./bridge`) |
69
+
70
+ Only `./bridge` loads `ethers` or `@solana/*`: the root and the other subpaths never do
71
+ (checked on the source by `pnpm run check:rn-safety` and the isolation test, and on the built files
72
+ by the packed smoke).
73
+
74
+ ## Bridge
75
+
76
+ ```typescript
77
+ import { BridgeableTokenService, BridgeService, GalaConnectClient } from '@gala-chain/gala-core-sdk/bridge';
78
+
79
+ const walletAddress = 'eth|...';
80
+ // The DEX API's bridgeable token list (production by default; `baseUrl` for another deployment)
81
+ const tokens = new BridgeableTokenService(new GalaConnectClient({ walletAddress }));
82
+ const bridge = new BridgeService({
83
+ environment: 'prod', // or 'stage': GalaConnect, the gateway and the RPCs of that deployment
84
+ galaChainWalletAddress: walletAddress,
85
+ ethereumPrivateKey: process.env.ETH_PRIVATE_KEY!, // signs the bridge-out request and Ethereum deposits
86
+ bridgeableTokenService: tokens, // resolves a token id to its bridge symbol
87
+ });
88
+ // Token ids are class keys (pipe form or object): a bare symbol is refused (symbols are not unique)
89
+ const GALA = 'GALA|Unit|none|none';
90
+ const fee = await bridge.estimateBridgeFee({ tokenId: GALA, destinationChain: 'Ethereum' });
91
+ const out = await bridge.bridgeOut({ tokenId: GALA, amount: '10', destinationChain: 'Ethereum', recipientAddress: '0x...' });
92
+ const status = await bridge.waitForBridgeCompletion(out.transactionHash);
93
+ ```
94
+
95
+ A bridge or wrap that does not complete throws a `GalaSDKError` (never a "failed" result). Once a
96
+ bridge-out request was accepted the tokens may be locked: a later failure is
97
+ `BRIDGE_OUT_OUTCOME_UNKNOWN` (with the step, the bridge request id and the `uniqueKey`), and a
98
+ deposit that may have been sent is `BRIDGE_DEPOSIT_OUTCOME_UNKNOWN`; neither is ever retried by the
99
+ SDK. `WrapService` wraps a token from its own channel to the asset channel (MUSIC to GMUSIC) and
100
+ back, signed natively by a `GalaChainSigner`.
101
+
102
+ TypeScript: the `./bridge` declarations name `@solana/web3.js` types, whose own declarations import
103
+ Node's `http` and `https`, so a TypeScript app that imports `./bridge` has `@types/node` (with
104
+ TypeScript 6, `"types": ["node"]`) or `skipLibCheck`. The other entries need no Node types.
105
+
106
+ ## Wallet providers
107
+
108
+ ```typescript
109
+ import { detectWallets, ExternalWalletProvider, PrivateKeyProvider } from '@gala-chain/gala-core-sdk/providers';
110
+
111
+ const { wallets } = await detectWallets(); // EIP-6963 announcements, then window.ethereum / window.gala
112
+ const provider = new ExternalWalletProvider(wallets[0].provider);
113
+ await provider.connect();
114
+ await provider.signMessage('Hello'); // personal_sign
115
+ const signer = provider.getSigner(); // a GalaChainSigner for GatewayWrites, gswap-sdk, ...
116
+
117
+ const server = new PrivateKeyProvider(process.env.GALACHAIN_PRIVATE_KEY!); // Node, CLI, bots
118
+ ```
119
+
120
+ A provider listens to its wallet only while connected, follows `accountsChanged` (an empty or
121
+ malformed account list disconnects it), and reads its connection once per operation, so one
122
+ operation never names two accounts. `getSigner()` is bound to the account connected when it is
123
+ called: after an account change, get a new signer. `GalaWalletProvider` selects its account in the
124
+ extension before each signature, serialized with every other signer of the same extension. Every
125
+ failure is a `GalaSDKError`: `WALLET_CONNECTION_FAILED` (`user_rejected`, `no_accounts`, `failed`),
126
+ `WALLET_NOT_CONNECTED`, `SIGNING_FAILED` (`user_rejected` when the person declined),
127
+ `INVALID_SIGNATURE`, `PRIVATE_KEY_NOT_ACCESSIBLE`, `INVALID_WALLET_PROVIDER_CONFIG`. Detection
128
+ works without a window (Node, SSR, React Native): it finds nothing and throws nothing.
129
+
130
+ ## React
131
+
132
+ ```tsx
133
+ import { WalletProvider, useWalletConnection, useWalletDetection, useWallet } from '@gala-chain/gala-core-sdk/react';
134
+
135
+ <WalletProvider autoDetect>
136
+ <App />
137
+ </WalletProvider>;
138
+
139
+ const { wallets } = useWalletDetection();
140
+ const { connectDetected } = useWalletConnection(); // a GalaWalletProvider for Gala Wallet, an ExternalWalletProvider otherwise
141
+ const { address, galaAddress, isConnected } = useWallet();
142
+ ```
143
+
144
+ The address follows the wallet (account switches, a wallet-side disconnect); the latest connect
145
+ wins over a slower earlier one; a provider the context created is released when it is replaced, when
146
+ its connect fails and on unmount; `initialProvider` is connected once. A hook outside
147
+ `<WalletProvider>` is `WALLET_CONTEXT_MISSING`. It renders on the server (no window, nothing
148
+ detected). `./react` does not re-export the providers: import them from `./providers`.
149
+
150
+ Every error core throws is a `GalaSDKError` with a stable `code`, flat `params` for an app's own
151
+ localization and a `phase` (`pre_send`: nothing was transmitted). The codes are listed in
152
+ [docs/error-catalog.md](./docs/error-catalog.md). A product SDK's error class extends
153
+ `GalaSDKError` and adds its own codes; `isGalaError(error)` recognises an error from any of them.
154
+
155
+ ## Gateway writes
156
+
157
+ ```typescript
158
+ import { GatewayWrites, PrivateKeySigner } from '@gala-chain/gala-core-sdk';
159
+
160
+ const writes = new GatewayWrites({
161
+ gatewayBaseUrl: 'https://gateway-mainnet.galachain.com',
162
+ signer: new PrivateKeySigner(process.env.GALACHAIN_PRIVATE_KEY!),
163
+ walletAddress: 'eth|70997970C51812dc3A010C7d01b50e0d17dc79C8', // or a client| alias
164
+ });
165
+
166
+ const { transactionId, blockNumber } = await writes.transferGala({ to: 'client|abc', quantity: '1.5' });
167
+ await writes.lockTokens({ tokens: [{ tokenClassKey: 'GALA|Unit|none|none', quantity: '10' }], expires: 0 });
168
+ ```
169
+
170
+ - Quantities are WHOLE tokens, as the decimal string the chain receives; they are signed exactly as
171
+ written (`"1.50"` stays `"1.50"`) and never scaled.
172
+ - Tokens: `tokenClassKey` (`collection|category|type|additionalKey` with exactly four parts, the
173
+ `$` composite key, or the object) plus `instance` (default `"0"`), or `tokenName` through an
174
+ optional `tokenNameResolver`. A bare symbol is never a class key.
175
+ - Identities (`to`, `walletAddress`, `lockAuthority`): an Ethereum account (`eth|<40 hex>`,
176
+ `eth|0x<40 hex>`, `0x<40 hex>`, bare hex; any casing but a wrong EIP-55 checksum) is always sent
177
+ as `eth|<checksummed>`, the only spelling the gateway accepts; `client|<id>` is sent as written.
178
+ - The signer is handed the bare DTO; the body sent is exactly the DTO plus the signature (a signer
179
+ that adds or changes a field is refused). A `uniqueKey` is minted per write unless you pass one.
180
+ - GalaChain's `Status` is checked before anything else is trusted; a timeout or broken connection is
181
+ `GATEWAY_WRITE_OUTCOME_UNKNOWN`: the write may have been applied, so check its `uniqueKey` and
182
+ never resend it under a fresh key.
183
+
184
+ ## Gateway reads
185
+
186
+ ```typescript
187
+ import { GALA_CHAIN_ENVIRONMENTS, GatewayReads } from '@gala-chain/gala-core-sdk';
188
+
189
+ const reads = new GatewayReads({ gatewayBaseUrl: GALA_CHAIN_ENVIRONMENTS.prod.gatewayBaseUrl });
190
+
191
+ const gala = await reads.fetchTokenBalance({ owner: 'client|abc', tokenClassKey: 'GALA|Unit|none|none' });
192
+ console.log(gala?.quantity, gala?.lockedQuantity, gala?.availableQuantity); // whole-token strings
193
+
194
+ const { symbol, decimals } = await reads.fetchTokenDetails('GUSDC|Unit|none|none');
195
+ const classes = await reads.fetchAllTokenClasses({ collection: 'BONKTactics' }, { maxPages: 10 });
196
+ ```
197
+
198
+ - Reads are unsigned and apply nothing: every failure after the request left says so
199
+ (`error.write === false`), and a retry is always safe.
200
+ - Owners are spelled as the writes spell them (an Ethereum account in any form as
201
+ `eth|<checksummed>`, `client|` as written); class keys are accepted in the same forms. `$MUSIC` balances are read on the gateway's
202
+ `music` channel.
203
+ - Every answer is checked (GalaChain's `Status`, then each row) before it is returned; a balance of
204
+ another owner than the one asked for is refused. Quantities stay the chain's whole-token decimal
205
+ strings; hold totals are exact and never in exponent form.
206
+ - A token class that does not exist is `TOKEN_CLASS_NOT_FOUND`; a `fetchAll...` read that would
207
+ need more than `maxPages` pages is `PAGINATION_LIMIT_EXCEEDED` (never a truncated list).
208
+
209
+ ## Signing parity
210
+
211
+ The signing code is pinned byte-for-byte to `@gala-chain/api`, wallet_extension and frontend_v2 by
212
+ the golden vectors in `tests/fixtures/wallet-signing-golden.json` and
213
+ `tests/fixtures/frontend-signing-golden.json` (`tests/signing-golden.test.ts`). They are never
214
+ regenerated to make a test pass; see gswap-sdk's `SIGNING-PARITY.md` for their provenance.
215
+
216
+ ## React Native
217
+
218
+ The shipped source uses no Node builtin, no `Buffer`, no `process`, and never loads `ethers`,
219
+ `axios` or `@gala-chain/api` (`pnpm run check:rn-safety`, also run by the test suite). The only
220
+ polyfill React Native/Hermes needs is `crypto.getRandomValues`, for minting `uniqueKey`s and new
221
+ random wallets (`createWallet()`):
222
+
223
+ ```typescript
224
+ import 'react-native-get-random-values'; // once, before the SDK mints a key
225
+ ```
226
+
227
+ Without it, minting a key or a wallet throws `CSPRNG_UNAVAILABLE` (never a weaker fallback).
228
+
229
+ `./bridge` is the exception: it loads `ethers`, `@solana/web3.js` and `@solana/spl-token`, and an
230
+ app that imports it on React Native also installs what those libraries ask for there
231
+ (`crypto.getRandomValues` above, which `createSolanaWallet` needs too; `@solana/web3.js`'s React
232
+ Native guidance adds a global `Buffer` from the `buffer` package). Core's own `./bridge` code uses
233
+ no `Buffer` or `process` global (Solana instruction data are `Uint8Array`s) and touches none at
234
+ module load: the guard allows `./bridge` exactly those three packages and nothing else (base58 is
235
+ `@scure/base`, pure JS like the rest of core).
236
+
237
+ ## Bundle size
238
+
239
+ `sideEffects: false`, and the browser build is one file per source module, so an app (or a product
240
+ SDK's light module) that imports one helper loads that module only.
241
+ `@gala-chain/gala-core-sdk/wallet` holds only the dependency-free wallet helpers (about 1.2 kB
242
+ minified, capped at 2 kB). `tests/tree_shaking.test.ts` budgets every shell-safe helper. The
243
+ browser builds of `./providers` (about 17 kB minified, 7.6 kB gzipped, most of it the known wallets'
244
+ icons), `./react` (about 4 kB, 1.7 kB gzipped) and `./bridge` (about 60 kB minified, 16 kB
245
+ gzipped, before `ethers` and `@solana/*`) are loaded only by an app that imports them.
246
+
247
+ ## Status
248
+
249
+ 1.0.0-rc.5 (rc.5: every Ethereum account a read, write or GalaConnect client sends is
250
+ `eth|<EIP-55>`, the only spelling the gateway accepts; `galaChainUserRef` is exported. rc.4:
251
+ `bridgeableTokenService` is required). In: signing, signers, transport and the error model (rc.0, from gswap-sdk); the
252
+ gateway token writes (rc.1, from launchpad-sdk's transfer and lock services, which now delegate
253
+ here); the gateway token reads (rc.2: balances, token classes, NFT collection authorizations, from
254
+ launchpad-sdk's balance and token services, which now delegate here) and the deployment endpoints;
255
+ the wallet providers (`./providers`), React hooks (`./react`), wallet helpers (`createWallet`
256
+ and the key derivations) and the bridge (`./bridge`: bridging, the token lists, wrap / unwrap,
257
+ `createSolanaWallet`) (rc.3, from launchpad-sdk's `/wallet`, `/react`, `helpers/wallet`, `bridge/`
258
+ and its bridgeable / wrappable token and wrap services, which are gone).
259
+
260
+ ## Migrating from gswap-sdk 1.x
261
+
262
+ See [MIGRATING-FROM-GSWAP.md](./MIGRATING-FROM-GSWAP.md): every moved export, old path to new
263
+ path, and the renamed error and brand identifiers.
264
+
265
+ ## License
266
+
267
+ Apache License 2.0.