Skip to content

Commit

Permalink
chore(x/nft): add nft type definitions and methods to api spec
Browse files Browse the repository at this point in the history
Ref: #33
  • Loading branch information
Jorge-Lopes committed Jun 4, 2024
1 parent ca0b69b commit f7470aa
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 1 deletion.
1 change: 1 addition & 0 deletions packages/orchestration/src/facade.js
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,7 @@ export const makeOrchestrationFacade = ({
},
getBrandInfo: anyVal,
asAmount: anyVal,
asNftAmount: anyVal,
};
return async (...args) => fn(orc, ctx, ...args);
},
Expand Down
37 changes: 36 additions & 1 deletion packages/orchestration/src/orchestration-api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,15 @@
import type {
Amount,
Brand,
CopyBagAmount,
CopySetAmount,
NatAmount,
Payment,
} from '@agoric/ertp/src/types.js';
import type { LocalChainAccount } from '@agoric/vats/src/localchain.js';
import type { Timestamp } from '@agoric/time';
import type { IBCMsgTransferOptions, KnownChains } from './types.js';
import { Any } from '@agoric/cosmic-proto/google/protobuf/any.js';

/**
* A denom that designates a path to a token type on some blockchain.
Expand Down Expand Up @@ -48,6 +51,24 @@ export type DenomAmount = {
/** Amounts can be provided as pure data using denoms or as ERTP Amounts */
export type AmountArg = DenomAmount | Amount;

/**
* A denom that designates a path to a non-fungible token Class on some remote blockchain.
* A distinct type definition was made to avoid conflicts with the 'Denom'.
* */
export type NftDenom = string;

export type NftDenomArg = NftDenom | Brand;

export type NftDenomAmount = {
brand: NftDenom;
value: {
id: string;
uri: string;
uri_hash:string;
data: Any;
};
};

/** An address on some blockchain, e.g., cosmos, eth, etc. */
export type ChainAddress = {
/** e.g. 1 for Ethereum, agoric-3 for Agoric, cosmoshub-4 for Cosmos */
Expand Down Expand Up @@ -117,6 +138,15 @@ export interface Orchestrator {
* @returns the Amount in local structuerd format
*/
asAmount: (amount: DenomAmount) => NatAmount;

/**
* Convert an NFT amount described in native data to a local, structured Amount.
* @param amount - the described amount
* @returns the Amount in local structured format as either CopySet or CopyBag
*/
asNftAmount: (
amount: NftDenomAmount,
) => CopySetAmount<NftDenomAmount['brand']> | CopyBagAmount<NftDenomAmount['brand']>;
}

/**
Expand All @@ -134,6 +164,11 @@ export interface OrchestrationAccountI {
/** @returns the balance of a specific denom for the account. */
getBalance: (denom: DenomArg) => Promise<DenomAmount>;

/** @returns an array of amounts for every NFT in the account. */
getNftBalances: () => Promise<NftDenomAmount[]>;

getNftBalance: (brand: NftDenomArg) => Promise<NftDenomAmount>;

/**
* Transfer amount to another account on the same chain. The promise settles when the transfer is complete.
* @param toAccount - the account to send the amount to. MUST be on the same chain
Expand Down Expand Up @@ -192,4 +227,4 @@ export type SwapMaxSlippage = {
amountIn: Amount;
brandOut: Brand;
slippage: number;
};
};

0 comments on commit f7470aa

Please sign in to comment.