Skip to content

feat: add Apt NFT collection skeleton #6129

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 15, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
62 changes: 62 additions & 0 deletions modules/sdk-coin-apt/src/aptNFTCollection.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
import { Apt } from './apt';
import { BitGoBase, CoinConstructor, NamedCoinConstructor } from '@bitgo/sdk-core';
import { AptNFTCollectionConfig, coins, tokens } from '@bitgo/statics';

export class AptNFTCollection extends Apt {
public readonly nftCollectionConfig: AptNFTCollectionConfig;

constructor(bitgo: BitGoBase, nftCollectionConfig: AptNFTCollectionConfig) {
const staticsCoin = nftCollectionConfig.network === 'Mainnet' ? coins.get('apt') : coins.get('tapt');
super(bitgo, staticsCoin);
this.nftCollectionConfig = nftCollectionConfig;
}

static createNFTCollectionConstructor(config: AptNFTCollectionConfig): CoinConstructor {
return (bitgo: BitGoBase) => new AptNFTCollection(bitgo, config);
}
static createNFTCollectionConstructors(
nftCollectionConfigs: AptNFTCollectionConfig[] = [
...tokens.bitcoin.apt.nftCollections,
...tokens.testnet.apt.nftCollections,
]
): NamedCoinConstructor[] {
const nftCollectionCtors: NamedCoinConstructor[] = [];
for (const config of nftCollectionConfigs) {
const nftCollectionConstructor = AptNFTCollection.createNFTCollectionConstructor(config);
nftCollectionCtors.push({ name: config.type, coinConstructor: nftCollectionConstructor });
}
return nftCollectionCtors;
}

get name(): string {
return this.nftCollectionConfig.name;
}

get coin(): string {
return this.nftCollectionConfig.coin;
}

get network(): string {
return this.nftCollectionConfig.network;
}

get nftCollectionId(): string {
return this.nftCollectionConfig.nftCollectionId;
}

getChain(): string {
return this.nftCollectionConfig.type;
}

getBaseChain(): string {
return this.coin;
}

getFullName(): string {
return 'Apt NFT Collection';
}

getBaseFactor(): number {
return Math.pow(10, this.nftCollectionConfig.decimalPlaces);
}
}
1 change: 1 addition & 0 deletions modules/sdk-coin-apt/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ export * from './register';
export * from './apt';
export * from './tapt';
export * from './aptToken';
export * from './aptNFTCollection';
4 changes: 4 additions & 0 deletions modules/sdk-coin-apt/src/register.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,15 @@ import { BitGoBase } from '@bitgo/sdk-core';
import { Apt } from './apt';
import { Tapt } from './tapt';
import { AptToken } from './aptToken';
import { AptNFTCollection } from './aptNFTCollection';

export const register = (sdk: BitGoBase): void => {
sdk.register('apt', Apt.createInstance);
sdk.register('tapt', Tapt.createInstance);
AptToken.createTokenConstructors().forEach(({ name, coinConstructor }) => {
sdk.register(name, coinConstructor);
});
AptNFTCollection.createNFTCollectionConstructors().forEach(({ name, coinConstructor }) => {
sdk.register(name, coinConstructor);
});
};
1 change: 1 addition & 0 deletions modules/statics/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ export {
SuiCoin,
XrpCoin,
AptCoin,
AptNFTCollection,
Sip10Token,
} from './account';
export { CoinMap } from './map';
Expand Down
29 changes: 29 additions & 0 deletions modules/statics/src/tokenConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import {
AdaCoin,
AlgoCoin,
AptCoin,
AptNFTCollection,
ArbethERC20Token,
AvaxERC20Token,
BeraERC20Token,
Expand Down Expand Up @@ -96,6 +97,10 @@ export type AptTokenConfig = BaseNetworkConfig & {
assetId: string;
};

export type AptNFTCollectionConfig = BaseNetworkConfig & {
nftCollectionId: string;
};

export type Sip10TokenConfig = BaseNetworkConfig & {
assetId: string;
};
Expand Down Expand Up @@ -161,6 +166,7 @@ export interface Tokens {
};
apt: {
tokens: AptTokenConfig[];
nftCollections: AptNFTCollectionConfig[];
};
stx: {
tokens: Sip10TokenConfig[];
Expand Down Expand Up @@ -226,6 +232,7 @@ export interface Tokens {
};
apt: {
tokens: AptTokenConfig[];
nftCollections: AptNFTCollectionConfig[];
};
stx: {
tokens: Sip10TokenConfig[];
Expand Down Expand Up @@ -618,6 +625,21 @@ const getFormattedAptTokens = (customCoinMap = coins) =>
return acc;
}, []);

const getFormattedAptNFTCollections = (customCoinMap = coins) =>
customCoinMap.reduce((acc: AptNFTCollectionConfig[], coin) => {
if (coin instanceof AptNFTCollection) {
acc.push({
type: coin.name,
coin: coin.network.type === NetworkType.MAINNET ? 'apt' : 'tapt',
network: coin.network.type === NetworkType.MAINNET ? 'Mainnet' : 'Testnet',
name: coin.fullName,
nftCollectionId: coin.nftCollectionId,
decimalPlaces: coin.decimalPlaces,
});
}
return acc;
}, []);

const getFormattedSip10Tokens = (customCoinMap = coins) =>
customCoinMap.reduce((acc: Sip10TokenConfig[], coin) => {
if (coin instanceof Sip10Token) {
Expand All @@ -634,6 +656,7 @@ const getFormattedSip10Tokens = (customCoinMap = coins) =>
}, []);

export const getFormattedTokens = (coinMap = coins): Tokens => {
const formattedAptNFTCollections = getFormattedAptNFTCollections(coinMap);
return {
bitcoin: {
eth: {
Expand Down Expand Up @@ -697,6 +720,9 @@ export const getFormattedTokens = (coinMap = coins): Tokens => {
},
apt: {
tokens: getFormattedAptTokens(coinMap).filter((token) => token.network === 'Mainnet'),
nftCollections: formattedAptNFTCollections.filter(
(nftCollection: AptNFTCollectionConfig) => nftCollection.network === 'Mainnet'
),
},
stx: {
tokens: getFormattedSip10Tokens(coinMap).filter((token) => token.network === 'Mainnet'),
Expand Down Expand Up @@ -764,6 +790,9 @@ export const getFormattedTokens = (coinMap = coins): Tokens => {
},
apt: {
tokens: getFormattedAptTokens(coinMap).filter((token) => token.network === 'Testnet'),
nftCollections: formattedAptNFTCollections.filter(
(nftCollection: AptNFTCollectionConfig) => nftCollection.network === 'Testnet'
),
},
stx: {
tokens: getFormattedSip10Tokens(coinMap).filter((token) => token.network === 'Testnet'),
Expand Down