-
Notifications
You must be signed in to change notification settings - Fork 58
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor!: move asset info type from Cardano to Asset
rename Asset->AssetInfo, make AssetInfo.history nullable
- Loading branch information
1 parent
8220bfb
commit 212b670
Showing
21 changed files
with
142 additions
and
133 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
export * as util from './util'; | ||
export * from './NftMetadata'; | ||
export * from './types'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import { AssetFingerprint, AssetId, AssetName, PolicyId, TransactionId } from '../../Cardano'; | ||
import { NftMetadata } from './NftMetadata'; | ||
import { TokenMetadata } from './TokenMetadata'; | ||
|
||
export interface AssetMintOrBurn { | ||
transactionId: TransactionId; | ||
/** | ||
* Positive = mint | ||
* Negative = burn | ||
*/ | ||
quantity: bigint; | ||
} | ||
|
||
export interface AssetInfo { | ||
assetId: AssetId; | ||
policyId: PolicyId; | ||
name: AssetName; | ||
fingerprint: AssetFingerprint; | ||
quantity: bigint; | ||
/** | ||
* Sorted by slot | ||
*/ | ||
history?: AssetMintOrBurn[]; | ||
/** | ||
* CIP-0035 | ||
*/ | ||
metadata?: TokenMetadata; | ||
/** | ||
* CIP-0025 | ||
*/ | ||
nftMetadata?: NftMetadata; | ||
} |
4 changes: 2 additions & 2 deletions
4
packages/core/src/Asset/NftMetadata.ts → packages/core/src/Asset/types/NftMetadata.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
export interface TokenMetadataSizedIcon { | ||
/** | ||
* Most likely one of 16, 32, 64, 96, 128 | ||
* icons are assumed to be square | ||
*/ | ||
size: number; | ||
/** | ||
* MUST be either https, ipfs, or data. icon MUST be a browser supported image format. | ||
*/ | ||
icon: string; | ||
} | ||
|
||
/** | ||
* Either on-chain or off-chain asset metadata | ||
* | ||
* CIP-0035 | ||
* https://github.com/cardano-foundation/CIPs/pull/137 | ||
*/ | ||
export interface TokenMetadata { | ||
/** | ||
* Asset name | ||
*/ | ||
name?: string; | ||
/** | ||
* when present, field and overrides default ticker which is the asset name | ||
*/ | ||
ticker?: string; | ||
/** | ||
* MUST be either https, ipfs, or data. icon MUST be a browser supported image format. | ||
*/ | ||
icon?: string; | ||
/** | ||
* allows teams to provide icon in different sizes | ||
*/ | ||
sizedIcons?: TokenMetadataSizedIcon[]; | ||
/** | ||
* https only url that refers to metadata stored offchain. | ||
* The URL SHOULD use the project domain and | ||
* MUST return authenticity metadata in either html or json format (see below) | ||
*/ | ||
url?: string; | ||
/** | ||
* additional description that defines the usage of the token | ||
*/ | ||
desc?: string; | ||
/** | ||
* how many decimal places should the token support? For ADA, this would be 6 e.g. 1 ADA is 10^6 Lovelace | ||
*/ | ||
decimals?: number; | ||
/** | ||
* https only url that holds the metadata in the onchain format. | ||
* The URL SHOULD use the project domain and MUST return the token metadata as described above | ||
*/ | ||
ref?: string; | ||
/** | ||
* when not specified, version will default to `1.0` | ||
*/ | ||
version?: '1.0'; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
export * from './NftMetadata'; | ||
export * from './TokenMetadata'; | ||
export * from './AssetInfo'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,9 @@ | ||
import { Cardano } from '../..'; | ||
import { Asset, Cardano } from '../..'; | ||
|
||
export interface AssetProvider { | ||
/** | ||
* @param id asset ID (concatenated hex values of policyId + assetName) | ||
* @throws ProviderError | ||
*/ | ||
getAsset: (id: Cardano.AssetId) => Promise<Cardano.Asset>; | ||
getAsset: (id: Cardano.AssetId) => Promise<Asset.AssetInfo>; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,5 @@ | ||
import { Asset } from '../../Cardano'; | ||
import { NftMetadata } from '../../Asset'; | ||
import { AssetInfo, NftMetadata } from '../../Asset'; | ||
|
||
export interface NftMetadataProvider { | ||
(asset: Asset): Promise<NftMetadata | undefined>; | ||
(asset: AssetInfo): Promise<NftMetadata | undefined>; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.