@glamsystems/glam-sdk 1.0.14-alpha.1 → 1.0.14-alpha.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/index.cjs.js CHANGED
@@ -18891,6 +18891,7 @@ var instructions$8 = [
18891
18891
  },
18892
18892
  {
18893
18893
  name: "glam_vault",
18894
+ writable: true,
18894
18895
  pda: {
18895
18896
  seeds: [
18896
18897
  {
@@ -19160,6 +19161,7 @@ var instructions$8 = [
19160
19161
  },
19161
19162
  {
19162
19163
  name: "glam_vault",
19164
+ writable: true,
19163
19165
  pda: {
19164
19166
  seeds: [
19165
19167
  {
@@ -47097,19 +47099,51 @@ class BaseClient {
47097
47099
  this._assetMetasPromise = undefined;
47098
47100
  }
47099
47101
  const fetchPromise = this.fetchGlobalConfig(options).then(async (globalConfig)=>{
47100
- // FIX: this could be perf bottleneck if there are many assets
47101
- const mintInfos = await fetchMintsAndTokenPrograms(this.connection, globalConfig.assetMetas.map((am)=>am.asset));
47102
- // Transforms onchain asset meta to client asset meta
47103
- const assetMetaMap = new Map(globalConfig.assetMetas.map(({ asset, decimals, oracle, oracleSource }, i)=>[
47104
- asset.toBase58(),
47105
- {
47106
- asset,
47107
- decimals,
47108
- oracle,
47109
- oracleSource,
47110
- programId: mintInfos[i].tokenProgram
47102
+ const assets = globalConfig.assetMetas.map((am)=>am.asset);
47103
+ const tokenProgramsByAsset = new Map();
47104
+ try {
47105
+ // Fast path when every global-config mint account is available.
47106
+ const mintInfos = await fetchMintsAndTokenPrograms(this.connection, assets);
47107
+ assets.forEach((asset, i)=>{
47108
+ tokenProgramsByAsset.set(asset.toBase58(), mintInfos[i].tokenProgram);
47109
+ });
47110
+ } catch {
47111
+ // Local validators may clone a newer global config than the set of
47112
+ // mint accounts they have available. Resolve what we can and let
47113
+ // downstream callers request only the assets they actually use.
47114
+ const accountsInfo = await this.connection.getMultipleAccountsInfo(assets, "confirmed");
47115
+ accountsInfo.forEach((accountInfo, i)=>{
47116
+ const asset = assets[i];
47117
+ const assetKey = asset.toBase58();
47118
+ if (accountInfo) {
47119
+ tokenProgramsByAsset.set(assetKey, parseMintAccountInfo(accountInfo, asset).tokenProgram);
47120
+ return;
47121
+ }
47122
+ const fallback = ASSETS_MAINNET.get(assetKey);
47123
+ if (fallback) {
47124
+ tokenProgramsByAsset.set(assetKey, fallback.programId);
47111
47125
  }
47112
- ]));
47126
+ });
47127
+ }
47128
+ // Transforms onchain asset meta to client asset meta
47129
+ const assetMetaMap = new Map(globalConfig.assetMetas.flatMap(({ asset, decimals, oracle, oracleSource })=>{
47130
+ const programId = tokenProgramsByAsset.get(asset.toBase58());
47131
+ if (!programId) {
47132
+ return [];
47133
+ }
47134
+ return [
47135
+ [
47136
+ asset.toBase58(),
47137
+ {
47138
+ asset,
47139
+ decimals,
47140
+ oracle,
47141
+ oracleSource,
47142
+ programId
47143
+ }
47144
+ ]
47145
+ ];
47146
+ }));
47113
47147
  if (useCache) {
47114
47148
  this._assetMetas = assetMetaMap;
47115
47149
  }
@@ -53498,10 +53532,9 @@ let TxBuilder$1 = class TxBuilder extends BaseTxBuilder {
53498
53532
  }).instruction();
53499
53533
  }
53500
53534
  async deleteLayerzeroOftRouteIx(route, signer) {
53501
- return await this.client.base.extBridgeProgram.methods.deleteLayerzeroOftRoute(normalizeRoute(route)).accountsPartial({
53535
+ return await this.client.base.extBridgeProgram.methods.deleteLayerzeroOftRoute(normalizeRoute(route)).accounts({
53502
53536
  glamState: this.client.base.statePda,
53503
- glamSigner: signer || this.client.base.signer,
53504
- glamProtocolProgram: this.client.base.protocolProgram.programId
53537
+ glamSigner: signer || this.client.base.signer
53505
53538
  }).instruction();
53506
53539
  }
53507
53540
  async buildOftTransferTx(params, txOptions = {}) {
@@ -53879,10 +53912,17 @@ class BridgeClient {
53879
53912
  return await this.base.sendAndConfirm(tx);
53880
53913
  }
53881
53914
  async reconcileManagedTransfer(transferId, txOptions = {}) {
53882
- const ix = await this.base.extBridgeProgram.methods.reconcileManagedTransfer().accountsPartial({
53915
+ web3_js.PublicKey.findProgramAddressSync([
53916
+ Buffer.from(SEED_INTEGRATION_AUTHORITY)
53917
+ ], this.base.extBridgeProgram.programId)[0];
53918
+ const ix = await this.base.extBridgeProgram.methods.reconcileManagedTransfer().accounts({
53883
53919
  glamState: this.base.statePda,
53920
+ // glamVault: this.base.vaultPda,
53884
53921
  glamSigner: txOptions.signer || this.base.signer,
53885
- glamProtocolProgram: this.base.protocolProgram.programId,
53922
+ // integrationAuthority,
53923
+ // glamProtocolProgram: this.base.protocolProgram.programId,
53924
+ // systemProgram: SystemProgram.programId,
53925
+ // bridgeRegistry: this.getRegistryPda(),
53886
53926
  transferRecord: this.getTransferRecordPda(transferId)
53887
53927
  }).instruction();
53888
53928
  const tx = await this.txBuilder.buildVersionedTx([
package/index.esm.js CHANGED
@@ -18871,6 +18871,7 @@ var instructions$8 = [
18871
18871
  },
18872
18872
  {
18873
18873
  name: "glam_vault",
18874
+ writable: true,
18874
18875
  pda: {
18875
18876
  seeds: [
18876
18877
  {
@@ -19140,6 +19141,7 @@ var instructions$8 = [
19140
19141
  },
19141
19142
  {
19142
19143
  name: "glam_vault",
19144
+ writable: true,
19143
19145
  pda: {
19144
19146
  seeds: [
19145
19147
  {
@@ -47077,19 +47079,51 @@ class BaseClient {
47077
47079
  this._assetMetasPromise = undefined;
47078
47080
  }
47079
47081
  const fetchPromise = this.fetchGlobalConfig(options).then(async (globalConfig)=>{
47080
- // FIX: this could be perf bottleneck if there are many assets
47081
- const mintInfos = await fetchMintsAndTokenPrograms(this.connection, globalConfig.assetMetas.map((am)=>am.asset));
47082
- // Transforms onchain asset meta to client asset meta
47083
- const assetMetaMap = new Map(globalConfig.assetMetas.map(({ asset, decimals, oracle, oracleSource }, i)=>[
47084
- asset.toBase58(),
47085
- {
47086
- asset,
47087
- decimals,
47088
- oracle,
47089
- oracleSource,
47090
- programId: mintInfos[i].tokenProgram
47082
+ const assets = globalConfig.assetMetas.map((am)=>am.asset);
47083
+ const tokenProgramsByAsset = new Map();
47084
+ try {
47085
+ // Fast path when every global-config mint account is available.
47086
+ const mintInfos = await fetchMintsAndTokenPrograms(this.connection, assets);
47087
+ assets.forEach((asset, i)=>{
47088
+ tokenProgramsByAsset.set(asset.toBase58(), mintInfos[i].tokenProgram);
47089
+ });
47090
+ } catch {
47091
+ // Local validators may clone a newer global config than the set of
47092
+ // mint accounts they have available. Resolve what we can and let
47093
+ // downstream callers request only the assets they actually use.
47094
+ const accountsInfo = await this.connection.getMultipleAccountsInfo(assets, "confirmed");
47095
+ accountsInfo.forEach((accountInfo, i)=>{
47096
+ const asset = assets[i];
47097
+ const assetKey = asset.toBase58();
47098
+ if (accountInfo) {
47099
+ tokenProgramsByAsset.set(assetKey, parseMintAccountInfo(accountInfo, asset).tokenProgram);
47100
+ return;
47101
+ }
47102
+ const fallback = ASSETS_MAINNET.get(assetKey);
47103
+ if (fallback) {
47104
+ tokenProgramsByAsset.set(assetKey, fallback.programId);
47091
47105
  }
47092
- ]));
47106
+ });
47107
+ }
47108
+ // Transforms onchain asset meta to client asset meta
47109
+ const assetMetaMap = new Map(globalConfig.assetMetas.flatMap(({ asset, decimals, oracle, oracleSource })=>{
47110
+ const programId = tokenProgramsByAsset.get(asset.toBase58());
47111
+ if (!programId) {
47112
+ return [];
47113
+ }
47114
+ return [
47115
+ [
47116
+ asset.toBase58(),
47117
+ {
47118
+ asset,
47119
+ decimals,
47120
+ oracle,
47121
+ oracleSource,
47122
+ programId
47123
+ }
47124
+ ]
47125
+ ];
47126
+ }));
47093
47127
  if (useCache) {
47094
47128
  this._assetMetas = assetMetaMap;
47095
47129
  }
@@ -53478,10 +53512,9 @@ let TxBuilder$1 = class TxBuilder extends BaseTxBuilder {
53478
53512
  }).instruction();
53479
53513
  }
53480
53514
  async deleteLayerzeroOftRouteIx(route, signer) {
53481
- return await this.client.base.extBridgeProgram.methods.deleteLayerzeroOftRoute(normalizeRoute(route)).accountsPartial({
53515
+ return await this.client.base.extBridgeProgram.methods.deleteLayerzeroOftRoute(normalizeRoute(route)).accounts({
53482
53516
  glamState: this.client.base.statePda,
53483
- glamSigner: signer || this.client.base.signer,
53484
- glamProtocolProgram: this.client.base.protocolProgram.programId
53517
+ glamSigner: signer || this.client.base.signer
53485
53518
  }).instruction();
53486
53519
  }
53487
53520
  async buildOftTransferTx(params, txOptions = {}) {
@@ -53859,10 +53892,17 @@ class BridgeClient {
53859
53892
  return await this.base.sendAndConfirm(tx);
53860
53893
  }
53861
53894
  async reconcileManagedTransfer(transferId, txOptions = {}) {
53862
- const ix = await this.base.extBridgeProgram.methods.reconcileManagedTransfer().accountsPartial({
53895
+ PublicKey.findProgramAddressSync([
53896
+ Buffer.from(SEED_INTEGRATION_AUTHORITY)
53897
+ ], this.base.extBridgeProgram.programId)[0];
53898
+ const ix = await this.base.extBridgeProgram.methods.reconcileManagedTransfer().accounts({
53863
53899
  glamState: this.base.statePda,
53900
+ // glamVault: this.base.vaultPda,
53864
53901
  glamSigner: txOptions.signer || this.base.signer,
53865
- glamProtocolProgram: this.base.protocolProgram.programId,
53902
+ // integrationAuthority,
53903
+ // glamProtocolProgram: this.base.protocolProgram.programId,
53904
+ // systemProgram: SystemProgram.programId,
53905
+ // bridgeRegistry: this.getRegistryPda(),
53866
53906
  transferRecord: this.getTransferRecordPda(transferId)
53867
53907
  }).instruction();
53868
53908
  const tx = await this.txBuilder.buildVersionedTx([
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@glamsystems/glam-sdk",
3
- "version": "1.0.14-alpha.1",
3
+ "version": "1.0.14-alpha.2",
4
4
  "description": "TypeScript SDK for the GLAM Protocol",
5
5
  "main": "./index.cjs.js",
6
6
  "module": "./index.esm.js",
@@ -104,6 +104,7 @@ export type ExtBridge = {
104
104
  },
105
105
  {
106
106
  "name": "glamVault";
107
+ "writable": true;
107
108
  "pda": {
108
109
  "seeds": [
109
110
  {
@@ -373,6 +374,7 @@ export type ExtBridge = {
373
374
  },
374
375
  {
375
376
  "name": "glamVault";
377
+ "writable": true;
376
378
  "pda": {
377
379
  "seeds": [
378
380
  {