@keetanetwork/anchor 0.0.65 → 0.0.67

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/lib/chaining.d.ts CHANGED
@@ -1,6 +1,6 @@
1
- import { type lib as KeetaNetLib } from '@keetanetwork/keetanet-client';
1
+ import type { lib as KeetaNetLib } from '@keetanetwork/keetanet-client';
2
2
  import { KeetaNet } from "../client/index.js";
3
- import type { AssetLocationLike, AssetTransferInstructions, PickChainLocation, Rail, RecipientResolved } from "../services/asset-movement/common.js";
3
+ import type { AnchorTokenLocationMetadata, AssetLocationLike, AssetTransferInstructions, PickChainLocation, Rail, RecipientResolved } from "../services/asset-movement/common.js";
4
4
  import type { Resolver } from "./index.js";
5
5
  import type { ISOCurrencyCode } from '@keetanetwork/currency-info';
6
6
  import type { Account, GenericAccount, TokenAddress } from '@keetanetwork/keetanet-client/lib/account.js';
@@ -184,6 +184,16 @@ export interface AnchorChainingAssetInfo {
184
184
  pathLength: number;
185
185
  } | null;
186
186
  }
187
+ type AnchorChainingAssetInfoWithMetadata = AnchorChainingAssetInfo & {
188
+ metadata?: AnchorTokenLocationMetadata;
189
+ };
190
+ interface AnchorChainingResolveAssetsWithMetadataResult {
191
+ from: AnchorChainingAssetInfoWithMetadata[];
192
+ to: AnchorChainingAssetInfoWithMetadata[];
193
+ }
194
+ type AnchorChainingWithMetadataOptions = {
195
+ providerID?: string;
196
+ };
187
197
  type GetAccountForActionPayload = {
188
198
  type: 'assetMovement';
189
199
  providerMethod: 'initiateTransfer';
@@ -207,10 +217,17 @@ declare class AnchorGraph {
207
217
  resolver: Resolver;
208
218
  logger?: Logger | undefined;
209
219
  });
220
+ getAssetMovementProvidersForAsset(asset: AnchorChainingAsset, location: AssetLocationLike): Promise<null | {
221
+ [providerID: string]: {
222
+ provider: AssetMovementProvider;
223
+ };
224
+ }>;
210
225
  computeGraphNodes(): Promise<GraphNodeLike[]>;
211
226
  findPaths(input: AnchorChainingPathInput): Promise<GraphNodeLike[][]>;
212
227
  resolveAssets(filter?: AnchorChainingResolveAssetsFilter): Promise<AnchorChainingResolveAssetsResult>;
213
228
  listAssets(filter?: AnchorChainingListAssetsFilter): Promise<AnchorChainingAssetInfo[]>;
229
+ resolveAssetsWithMetadata(filter?: AnchorChainingResolveAssetsFilter, options?: AnchorChainingWithMetadataOptions): Promise<AnchorChainingResolveAssetsWithMetadataResult>;
230
+ listAssetsWithMetadata(filter?: AnchorChainingListAssetsFilter, options?: AnchorChainingWithMetadataOptions): Promise<AnchorChainingAssetInfoWithMetadata[]>;
214
231
  }
215
232
  export interface ComputePlanOptions {
216
233
  overrides?: AnchorChainingAccountOverrides;
@@ -1 +1 @@
1
- {"version":3,"file":"chaining.d.ts","sourceRoot":"","sources":["../../src/lib/chaining.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,GAAG,IAAI,WAAW,EAAE,MAAM,+BAA+B,CAAC;AACxE,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAC9C,OAAO,KAAK,EAAE,iBAAiB,EAAE,yBAAyB,EAA8D,iBAAiB,EAAE,IAAI,EAAiC,iBAAiB,EAAE,MAAM,sCAAsC,CAAC;AAEhP,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAE3C,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,6BAA6B,CAAC;AAEnE,OAAO,KAAK,EAAE,OAAO,EAAE,cAAc,EAAE,YAAY,EAAE,MAAM,8CAA8C,CAAC;AAK1G,OAAO,mBAAmB,MAAM,0BAA0B,CAAC;AAC3D,OAAO,8BAA8B,MAAM,sCAAsC,CAAC;AAClF,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAC;AAErD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AAC7C,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,kDAAkD,CAAC;AAElF,KAAK,iBAAiB,GAAG,WAAW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,EAAE,uBAAuB,EAAE,OAAO,CAAC,EAAE,kBAAkB,GAAG;QAAE,gBAAgB,CAAC,EAAE,KAAK,CAAA;KAAE,GAAG,OAAO,CAAC,kBAAkB,EAAE,GAAG,IAAI,CAAC;IAC3I,QAAQ,CAAC,KAAK,EAAE,uBAAuB,EAAE,OAAO,EAAE,kBAAkB,GAAG;QAAE,gBAAgB,EAAE,IAAI,CAAA;KAAE,GAAG,OAAO,CAAC,4BAA4B,EAAE,GAAG,IAAI,CAAC;CAuCxJ"}
package/lib/chaining.js CHANGED
@@ -64,11 +64,54 @@ class AnchorGraph {
64
64
  client;
65
65
  resolver;
66
66
  logger;
67
+ #assetMovementClient;
68
+ #assetMovementProviderCache = new Map();
67
69
  #assetNameCache = new Map();
70
+ #graphNodePromise = null;
68
71
  constructor(args) {
69
72
  this.resolver = args.resolver;
70
73
  this.client = args.client;
71
74
  this.logger = args.logger;
75
+ this.#assetMovementClient = new KeetaAssetMovementAnchorClient(this.client, {
76
+ resolver: this.resolver,
77
+ ...(this.logger ? { logger: this.logger } : {})
78
+ });
79
+ }
80
+ #assetLocationKey = (side) => {
81
+ return (`${convertAssetSearchInputToCanonical(side.asset)}@${convertAssetLocationToString(side.location)}`);
82
+ };
83
+ async #getAssetMovementProviderById(providerID) {
84
+ let provider = this.#assetMovementProviderCache.get(providerID);
85
+ if (provider === undefined) {
86
+ provider = await this.#assetMovementClient.getProviderByID(providerID);
87
+ }
88
+ this.#assetMovementProviderCache.set(providerID, provider);
89
+ return (provider);
90
+ }
91
+ async getAssetMovementProvidersForAsset(asset, location) {
92
+ let retval = null;
93
+ for (const node of await this.computeGraphNodes()) {
94
+ if (node.type !== 'assetMovement') {
95
+ continue;
96
+ }
97
+ for (const side of [node.from, node.to]) {
98
+ if (!isAnchorChainingAssetEqual(side.asset, asset) || convertAssetLocationToString(side.location) !== convertAssetLocationToString(location)) {
99
+ continue;
100
+ }
101
+ if (!retval) {
102
+ retval = {};
103
+ }
104
+ if (!retval[node.providerID]) {
105
+ const provider = await this.#getAssetMovementProviderById(node.providerID);
106
+ if (!provider) {
107
+ this.logger?.debug('AnchorGraph::getAssetMovementProvidersForAsset', `No provider found for providerID ${node.providerID}, although provider was previously known to exist in the graph nodes`);
108
+ continue;
109
+ }
110
+ retval[node.providerID] = { provider };
111
+ }
112
+ }
113
+ }
114
+ return (retval);
72
115
  }
73
116
  async #computeFXNodes() {
74
117
  const fxServices = await this.resolver.lookup('fx', {});
@@ -268,11 +311,16 @@ class AnchorGraph {
268
311
  return (providerResults.flat().filter((node) => !!node));
269
312
  }
270
313
  async computeGraphNodes() {
271
- const receivedNodes = await Promise.all([
272
- this.#computeFXNodes(),
273
- this.#computeAssetMovementNodes()
274
- ]);
275
- return (receivedNodes.flat());
314
+ if (this.#graphNodePromise === null) {
315
+ this.#graphNodePromise = (async () => {
316
+ const receivedNodes = await Promise.all([
317
+ this.#computeFXNodes(),
318
+ this.#computeAssetMovementNodes()
319
+ ]);
320
+ return (receivedNodes.flat());
321
+ })();
322
+ }
323
+ return (await this.#graphNodePromise);
276
324
  }
277
325
  async findPaths(input) {
278
326
  const graph = await this.computeGraphNodes();
@@ -363,9 +411,6 @@ class AnchorGraph {
363
411
  }
364
412
  }
365
413
  }
366
- const assetLocationKey = (side) => {
367
- return (`${convertAssetSearchInputToCanonical(side.asset)}@${convertAssetLocationToString(side.location)}`);
368
- };
369
414
  const sideMatchesFilter = (side, f) => {
370
415
  if (f.location !== undefined && convertAssetLocationToString(side.location) !== convertAssetLocationToString(f.location)) {
371
416
  return (false);
@@ -384,7 +429,7 @@ class AnchorGraph {
384
429
  const toReachable = new Set();
385
430
  const toDistances = new Map();
386
431
  const makeMarkFn = (reachable, distances) => (side, depth) => {
387
- const key = assetLocationKey(side);
432
+ const key = this.#assetLocationKey(side);
388
433
  reachable.add(key);
389
434
  if (depth !== undefined) {
390
435
  const existing = distances.get(key);
@@ -453,7 +498,7 @@ class AnchorGraph {
453
498
  const buildResultMap = (reachable, distances) => {
454
499
  const resultMap = new Map();
455
500
  const getOrCreate = (side) => {
456
- const key = assetLocationKey(side);
501
+ const key = this.#assetLocationKey(side);
457
502
  let resultObj = resultMap.get(key);
458
503
  if (!resultObj) {
459
504
  const distanceValue = distances.get(key);
@@ -471,13 +516,13 @@ class AnchorGraph {
471
516
  if (onlyAllowFXLike && !isFXLikeNode(node)) {
472
517
  continue;
473
518
  }
474
- if (reachable.has(assetLocationKey(node.to))) {
519
+ if (reachable.has(this.#assetLocationKey(node.to))) {
475
520
  const entry = getOrCreate(node.to);
476
521
  if (!entry.rails.inbound.includes(node.to.rail)) {
477
522
  entry.rails.inbound.push(node.to.rail);
478
523
  }
479
524
  }
480
- if (reachable.has(assetLocationKey(node.from))) {
525
+ if (reachable.has(this.#assetLocationKey(node.from))) {
481
526
  const entry = getOrCreate(node.from);
482
527
  if (!entry.rails.outbound.includes(node.from.rail)) {
483
528
  entry.rails.outbound.push(node.from.rail);
@@ -492,10 +537,10 @@ class AnchorGraph {
492
537
  // "what can USDC be swapped to?" doesn't include USDC itself via a round-trip.
493
538
  if (onlyAllowFXLike) {
494
539
  if (fromFilter?.asset !== undefined) {
495
- toResultMap.delete(assetLocationKey({ asset: fromFilter.asset, location: fromFilter.location ?? keetaNetworkLocation }));
540
+ toResultMap.delete(this.#assetLocationKey({ asset: fromFilter.asset, location: fromFilter.location ?? keetaNetworkLocation }));
496
541
  }
497
542
  if (toFilter?.asset !== undefined) {
498
- fromResultMap.delete(assetLocationKey({ asset: toFilter.asset, location: toFilter.location ?? keetaNetworkLocation }));
543
+ fromResultMap.delete(this.#assetLocationKey({ asset: toFilter.asset, location: toFilter.location ?? keetaNetworkLocation }));
499
544
  }
500
545
  }
501
546
  const filterMap = (map, f, railSide) => Array.from(map.values()).filter(info => {
@@ -530,6 +575,60 @@ class AnchorGraph {
530
575
  return (result.to);
531
576
  }
532
577
  }
578
+ async #attachMetadata(assetInfo, options) {
579
+ if (!isExternalChainAsset(assetInfo.asset)) {
580
+ return (assetInfo);
581
+ }
582
+ const providers = await this.getAssetMovementProvidersForAsset(assetInfo.asset, assetInfo.location);
583
+ if (!providers) {
584
+ return (assetInfo);
585
+ }
586
+ if (options?.providerID) {
587
+ const found = providers[options.providerID];
588
+ if (!found) {
589
+ return (assetInfo);
590
+ }
591
+ const metadata = found.provider.getAssetMetadataForLocation(assetInfo.location, assetInfo.asset);
592
+ if (!metadata) {
593
+ return (assetInfo);
594
+ }
595
+ return ({
596
+ ...assetInfo,
597
+ metadata
598
+ });
599
+ }
600
+ for (const { provider } of Object.values(providers)) {
601
+ const metadata = provider.getAssetMetadataForLocation(assetInfo.location, assetInfo.asset);
602
+ if (!metadata) {
603
+ continue;
604
+ }
605
+ return ({
606
+ ...assetInfo,
607
+ metadata
608
+ });
609
+ }
610
+ return (assetInfo);
611
+ }
612
+ async resolveAssetsWithMetadata(filter = {}, options) {
613
+ const result = await this.resolveAssets(filter);
614
+ const [from, to] = await Promise.all([
615
+ Promise.all(result.from.map((info) => this.#attachMetadata(info, options))),
616
+ Promise.all(result.to.map((info) => this.#attachMetadata(info, options)))
617
+ ]);
618
+ return ({ from, to });
619
+ }
620
+ async listAssetsWithMetadata(filter = {}, options) {
621
+ const result = await this.resolveAssetsWithMetadata(filter, options);
622
+ if (filter.from) {
623
+ return (result.to);
624
+ }
625
+ else if (filter.to) {
626
+ return (result.from);
627
+ }
628
+ else {
629
+ return (result.to);
630
+ }
631
+ }
533
632
  }
534
633
  export class AnchorChainingPath {
535
634
  request;
@@ -692,54 +791,52 @@ export class AnchorChainingPlan extends AnchorChainingPath {
692
791
  sendingToType = 'FINAL_DESTINATION';
693
792
  }
694
793
  else {
794
+ sendingToType = 'NEXT_STEP';
695
795
  const nextPathStep = this.path[index + 1];
696
- if (nextPathStep?.type === 'fx') {
697
- throw (new Error(`Cannot currently chain from asset movement to fx step, as fx step does not have recipient information`));
796
+ if (!nextPathStep) {
797
+ throw (new Error(`Expected next step at index ${index + 1} for asset movement step at index ${index}`));
698
798
  }
699
- const nextStep = await resolveStep(index + 1);
700
- if (nextStep.type === 'assetMovement' || nextStep.type === 'keetaSend') {
701
- if (nextStep.usingInstruction.type !== step.to.rail) {
702
- throw (new Error(`Next step's usingInstruction type ${nextStep.usingInstruction.type} does not match expected ${step.to.rail} for recipient resolution`));
703
- }
704
- const foundInstruction = nextStep.usingInstruction;
705
- const isFiatPushRailFoundInstruction = (input) => {
706
- return (isFiatRail(input.type));
707
- };
708
- if (foundInstruction.type === 'KEETA_SEND') {
709
- if (!KeetaNet.lib.Account.isInstance(step.to.asset)) {
710
- throw (new Error(`Expected asset to be a token account for KEETA_SEND rail`));
711
- }
712
- if (!step.to.asset.comparePublicKey(foundInstruction.tokenAddress)) {
713
- throw (new Error(`Recipient token account ${foundInstruction.tokenAddress.toString()} does not match expected ${step.to.asset.publicKeyString.get()}`));
799
+ if (nextPathStep.from.location === `chain:keeta:${this.parent['client'].network}`) {
800
+ const { account } = await this.getAccountsForAction({
801
+ type: 'assetMovement',
802
+ providerMethod: 'initiateTransfer'
803
+ }, this.#options?.overrides);
804
+ // Store funds in-transit in the account instead of forwarding directly to provider.
805
+ recipient = account;
806
+ }
807
+ else {
808
+ recipient = async () => {
809
+ const nextStep = await resolveStep(index + 1);
810
+ if (nextStep.type === 'assetMovement' || nextStep.type === 'keetaSend') {
811
+ if (nextStep.usingInstruction.type !== step.to.rail) {
812
+ throw (new Error(`Next step's usingInstruction type ${nextStep.usingInstruction.type} does not match expected ${step.to.rail} for recipient resolution`));
813
+ }
814
+ const foundInstruction = nextStep.usingInstruction;
815
+ const isFiatPushRailFoundInstruction = (input) => {
816
+ return (isFiatRail(input.type));
817
+ };
818
+ if (foundInstruction.type === 'KEETA_SEND') {
819
+ throw (new Error(`Cannot currently chain from asset movement to KEETA_SEND step, as this implies multiple keeta locations in the path which is not currently supported`));
820
+ }
821
+ else if (isFiatPushRailFoundInstruction(foundInstruction)) {
822
+ if (foundInstruction.depositMessage) {
823
+ throw (new Error(`Deposit message outbound is not currently supported for chaining`));
824
+ }
825
+ return (foundInstruction.account);
826
+ }
827
+ else {
828
+ throw (new Error(`Unsupported rail for chaining: ${step.to.rail}`));
829
+ }
714
830
  }
715
- if (foundInstruction.external) {
716
- throw (new Error(`Expected KEETA_SEND instruction to not have external value`));
831
+ else if (nextStep.type === 'fx') {
832
+ throw (new Error(`Cannot currently chain from asset movement to fx step, as fx step does not have recipient information`));
717
833
  }
718
- // XXX:TODO assert value here matches
719
- sendingToType = 'NEXT_STEP';
720
- recipient = KeetaNet.lib.Account.fromPublicKeyString(foundInstruction.sendToAddress);
721
- }
722
- else if (isFiatPushRailFoundInstruction(foundInstruction)) {
723
- if (foundInstruction.depositMessage) {
724
- throw (new Error(`Deposit message outbound is not currently supported for chaining`));
834
+ else {
835
+ assertNever(nextStep);
725
836
  }
726
- sendingToType = 'NEXT_STEP';
727
- recipient = foundInstruction.account;
728
- }
729
- else {
730
- throw (new Error(`Unsupported rail for chaining: ${step.to.rail}`));
731
- }
732
- }
733
- else if (nextStep.type === 'fx') {
734
- throw (new Error(`Cannot currently chain from asset movement to fx step, as fx step does not have recipient information`));
735
- }
736
- else {
737
- assertNever(nextStep);
837
+ };
738
838
  }
739
839
  }
740
- if (!recipient) {
741
- throw (new Error(`Recipient must be defined for asset movement step at index ${index}`));
742
- }
743
840
  const assetPair = { from: step.from.asset, to: step.to.asset };
744
841
  const providers = await assetMovementClient.getProvidersForTransfer({ asset: assetPair, from: step.from.location, to: step.to.location }, { providerIDs: [step.providerID] });
745
842
  if (!providers?.[0] || providers.length === 0) {
@@ -769,12 +866,19 @@ export class AnchorChainingPlan extends AnchorChainingPath {
769
866
  from: { location: step.from.location },
770
867
  to: {
771
868
  location: step.to.location,
772
- recipient: (() => {
773
- if (KeetaNet.lib.Account.isInstance(recipient)) {
774
- return (recipient.publicKeyString.get());
869
+ recipient: await (async () => {
870
+ let recipientResolved;
871
+ if (typeof recipient === 'function') {
872
+ recipientResolved = await recipient();
873
+ }
874
+ else {
875
+ recipientResolved = recipient;
876
+ }
877
+ if (KeetaNet.lib.Account.isInstance(recipientResolved)) {
878
+ return (recipientResolved.publicKeyString.get());
775
879
  }
776
880
  else {
777
- return (recipient);
881
+ return (recipientResolved);
778
882
  }
779
883
  })()
780
884
  },
@@ -1024,7 +1128,6 @@ export class AnchorChainingPlan extends AnchorChainingPath {
1024
1128
  let prevActualValueOut = null;
1025
1129
  let index = 0;
1026
1130
  try {
1027
- let prev = null;
1028
1131
  for (index = 0; index < this.plan.steps.length; index++) {
1029
1132
  const onStepCompleted = (step) => {
1030
1133
  executedSteps.push(step);
@@ -1051,42 +1154,22 @@ export class AnchorChainingPlan extends AnchorChainingPath {
1051
1154
  onStepCompleted({ type: 'fx', plan: step, exchange });
1052
1155
  }
1053
1156
  else if (step.type === 'assetMovement' || step.type === 'keetaSend') {
1054
- let userInitiatedTransferRequired;
1055
- if (prev && prev.type === 'assetMovement') {
1056
- if (prev.sendingTo === 'NEXT_STEP') {
1057
- userInitiatedTransferRequired = false;
1058
- }
1059
- else if (prev.sendingTo === 'FINAL_DESTINATION') {
1060
- throw (new Error(`Invalid path: step ${index - 1} is sending to final destination, but is followed by another step`));
1061
- }
1062
- else if (prev.sendingTo === 'SELF') {
1063
- userInitiatedTransferRequired = true;
1064
- }
1065
- else {
1066
- assertNever(prev.sendingTo);
1067
- }
1068
- }
1069
- else {
1070
- userInitiatedTransferRequired = true;
1157
+ if (step.usingInstruction.type === 'KEETA_SEND') {
1158
+ await this.#authorizedSend(options, step.usingInstruction.sendToAddress, BigInt(step.usingInstruction.value), KeetaNet.lib.Account.fromPublicKeyString(step.usingInstruction.tokenAddress).assertKeyType(KeetaNet.lib.Account.AccountKeyAlgorithm.TOKEN), step.usingInstruction.external);
1071
1159
  }
1072
- if (userInitiatedTransferRequired) {
1073
- if (step.usingInstruction.type === 'KEETA_SEND') {
1074
- await this.#authorizedSend(options, step.usingInstruction.sendToAddress, BigInt(step.usingInstruction.value), KeetaNet.lib.Account.fromPublicKeyString(step.usingInstruction.tokenAddress).assertKeyType(KeetaNet.lib.Account.AccountKeyAlgorithm.TOKEN), step.usingInstruction.external);
1160
+ else if (index === 0) {
1161
+ if (step.type !== 'assetMovement') {
1162
+ throw (new Error(`Unexpected asset movement step at index ${index} for user-initiated transfer`));
1075
1163
  }
1076
- else if (index === 0) {
1077
- if (step.type !== 'assetMovement') {
1078
- throw (new Error(`Unexpected asset movement step at index ${index} for user-initiated transfer`));
1164
+ await this.#awaitStepCompletion({
1165
+ type: 'assetMovementUserExecutionRequired',
1166
+ action: {
1167
+ assetMovementTransfer: step.transfer
1079
1168
  }
1080
- await this.#awaitStepCompletion({
1081
- type: 'assetMovementUserExecutionRequired',
1082
- action: {
1083
- assetMovementTransfer: step.transfer
1084
- }
1085
- });
1086
- }
1087
- else {
1088
- throw (new Error(`Unsupported instruction type ${step.usingInstruction.type} for user-initiated transfer at step ${index}`));
1089
- }
1169
+ });
1170
+ }
1171
+ else {
1172
+ throw (new Error(`Unsupported instruction type ${step.usingInstruction.type} for user-initiated transfer at step ${index}`));
1090
1173
  }
1091
1174
  if (step.type === 'assetMovement') {
1092
1175
  const status = await this.#pollTransferStatus(step.transfer);
@@ -1105,7 +1188,6 @@ export class AnchorChainingPlan extends AnchorChainingPath {
1105
1188
  else {
1106
1189
  assertNever(step);
1107
1190
  }
1108
- prev = step;
1109
1191
  }
1110
1192
  // Direct same-location/same-asset send: the loop ran zero iterations,
1111
1193
  // so just publish the on-chain transfer directly.