@gala-chain/gala-core-sdk 1.1.0-beta.5 → 1.1.0-beta.6

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 CHANGED
@@ -99,7 +99,9 @@ bridge-out request was accepted the tokens may be locked: a later failure is
99
99
  `BRIDGE_OUT_OUTCOME_UNKNOWN` (with the step, the bridge request id and the `uniqueKey`), and a
100
100
  deposit that may have been sent is `BRIDGE_DEPOSIT_OUTCOME_UNKNOWN`; neither is ever retried by the
101
101
  SDK. `WrapService` wraps a token from its own channel to the asset channel (MUSIC to GMUSIC) and
102
- back, signed natively by a `GalaChainSigner`. A `RequestTokenBridgeOut` (the bridge-out and the wrap /
102
+ back, signed natively by a `GalaChainSigner`; `createWrapService({ environment, walletAddress, signer })`
103
+ builds one for `prod` or `stage` (the environment supplies the GalaConnect, swap backend and gateway URLs;
104
+ an option overrides any), so a wrap needs no product SDK. A `RequestTokenBridgeOut` (the bridge-out and the wrap /
103
105
  unwrap) signs the TOKEN contract's `dtoOperation`
104
106
  (`asset-channel_basic-asset_GalaChainToken:RequestTokenBridgeOut`, not the bridge contract's, which the
105
107
  chain refuses; verified on stage, 2026-11-02) as a field of its EIP-712 `GalaTransaction` type, so the
@@ -300,7 +302,7 @@ gzipped, before `ethers` and `@solana/*`) are loaded only by an app that imports
300
302
 
301
303
  ## Status
302
304
 
303
- <!-- docs:var version -->1.1.0-beta.5<!-- /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()`;
305
+ <!-- docs:var version -->1.1.0-beta.6<!-- /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()`;
304
306
  rc.5: every Ethereum account a read, write or GalaConnect client sends is
305
307
  `eth|<EIP-55>`, the only spelling the gateway accepts, and `galaChainUserRef` is exported; rc.4:
306
308
  `bridgeableTokenService` is required). In: signing, signers, transport and the error model (rc.0, from gswap-sdk); the
package/dist/bridge.cjs CHANGED
@@ -4872,6 +4872,77 @@ function readWrapResult(bridgeOutResponse, bridgeRequestId) {
4872
4872
  return typeof hash === "string" && hash !== "" ? hash : bridgeRequestId;
4873
4873
  }
4874
4874
 
4875
+ //#endregion
4876
+ //#region src/config/environments.ts
4877
+ /**
4878
+ * The built-in endpoints of each deployment. A product SDK extends these with its own backends
4879
+ * (launchpad-sdk's launchpad and bundler URLs, gswap-sdk's swap backend); it never redefines them.
4880
+ */
4881
+ const GALA_CHAIN_ENVIRONMENTS = Object.freeze({
4882
+ prod: Object.freeze({
4883
+ gatewayBaseUrl: "https://gateway-mainnet.galachain.com",
4884
+ dexApiBaseUrl: "https://dex-api-platform-dex-prod-gala.gala.com",
4885
+ dexBackendBaseUrl: "https://dex-backend-prod1.defi.gala.com"
4886
+ }),
4887
+ stage: Object.freeze({
4888
+ gatewayBaseUrl: "https://gateway-testnet.galachain.com",
4889
+ dexApiBaseUrl: "https://dex-api-platform-dex-stage-gala.gala.com",
4890
+ dexBackendBaseUrl: "https://swap-backend.stage.defi.ovh.gala.com",
4891
+ eip712DomainName: "GalaChainStage"
4892
+ })
4893
+ });
4894
+
4895
+ //#endregion
4896
+ //#region src/bridge/tokens/createWrapService.ts
4897
+ /**
4898
+ * createWrapService
4899
+ *
4900
+ * Builds a {@link WrapService} for a deployment the way `BridgeService` builds its client: the
4901
+ * environment (`prod` by default, or `stage`) supplies the URLs, an option overrides any of them.
4902
+ *
4903
+ * @module bridge/tokens/createWrapService
4904
+ */
4905
+ /**
4906
+ * A {@link WrapService} for `options.environment`: wrap a token from its own channel to the asset
4907
+ * channel (MUSIC to GMUSIC) and unwrap it back.
4908
+ *
4909
+ * @param options - The environment, the wallet and its signer, optional URL overrides
4910
+ * @returns The wrap service, with its GalaConnect client and wrappable token list
4911
+ * @throws GalaSDKError `INVALID_BRIDGE_OPTION` (`environment`) for an environment that is not
4912
+ * `prod` or `stage`; the client's own (`walletAddress`, a URL option)
4913
+ *
4914
+ * @example
4915
+ * ```typescript
4916
+ * import { PrivateKeySigner } from '@gala-chain/gala-core-sdk';
4917
+ * import { createWrapService } from '@gala-chain/gala-core-sdk/bridge';
4918
+ *
4919
+ * const wrap = createWrapService({
4920
+ * environment: 'stage',
4921
+ * walletAddress: 'eth|70997970C51812dc3A010C7d01b50e0d17dc79C8',
4922
+ * signer: new PrivateKeySigner(privateKey),
4923
+ * });
4924
+ * const done = await wrap.unwrapToken({ tokenId: 'GMUSIC', amount: '1' });
4925
+ * ```
4926
+ */
4927
+ function createWrapService(options) {
4928
+ const environment = options.environment ?? "prod";
4929
+ const urls = Object.prototype.hasOwnProperty.call(GALA_CHAIN_ENVIRONMENTS, environment) ? GALA_CHAIN_ENVIRONMENTS[environment] : void 0;
4930
+ if (urls === void 0) throw new _gala_chain_gala_core_sdk.GalaSDKError("INVALID_BRIDGE_OPTION", { option: "environment" });
4931
+ const galaConnectClient = new GalaConnectClient({
4932
+ baseUrl: options.galaConnectBaseUrl ?? urls.dexApiBaseUrl,
4933
+ galachainBaseUrl: options.galaChainApiBaseUrl ?? urls.gatewayBaseUrl,
4934
+ dexBackendBaseUrl: options.dexBackendBaseUrl ?? urls.dexBackendBaseUrl,
4935
+ walletAddress: options.walletAddress,
4936
+ ...options.httpRequestor !== void 0 && { httpRequestor: options.httpRequestor }
4937
+ });
4938
+ return new WrapService({
4939
+ galaConnectClient,
4940
+ wrappableTokenService: new WrappableTokenService(galaConnectClient),
4941
+ walletAddress: options.walletAddress,
4942
+ ...options.signer !== void 0 && { signer: options.signer }
4943
+ });
4944
+ }
4945
+
4875
4946
  //#endregion
4876
4947
  //#region src/bridge/solanaWallet.ts
4877
4948
  /**
@@ -4972,6 +5043,7 @@ exports.WrappableTokenService = WrappableTokenService;
4972
5043
  exports.buildBridgeOutPayload = buildBridgeOutPayload;
4973
5044
  exports.compareAmounts = compareAmounts;
4974
5045
  exports.createSolanaWallet = createSolanaWallet;
5046
+ exports.createWrapService = createWrapService;
4975
5047
  exports.formatTokenAmount = formatTokenAmount;
4976
5048
  exports.formatTokenDescriptor = formatTokenDescriptor;
4977
5049
  exports.fromBaseUnits = fromBaseUnits;