@@ -142,6 +142,10 @@ export interface Sip10TokenConstructorOptions extends AccountConstructorOptions
142142 assetId : string ;
143143}
144144
145+ export interface Nep141TokenConstructorOptions extends AccountConstructorOptions {
146+ contractAddress : string ;
147+ }
148+
145149export interface ContractAddress extends String {
146150 __contractaddress_phantom__ : never ;
147151}
@@ -578,6 +582,21 @@ export class Sip10Token extends AccountCoinToken {
578582 }
579583}
580584
585+ /**
586+ * The Near network supports tokens
587+ * Near tokens work similar to native near coin
588+ */
589+ export class Nep141Token extends AccountCoinToken {
590+ public contractAddress : string ;
591+ constructor ( options : Nep141TokenConstructorOptions ) {
592+ super ( {
593+ ...options ,
594+ } ) ;
595+
596+ this . contractAddress = options . contractAddress ;
597+ }
598+ }
599+
581600/**
582601 * Factory function for account coin instances.
583602 *
@@ -2890,3 +2909,79 @@ export function tsip10Token(
28902909) {
28912910 return sip10Token ( id , name , fullName , decimalPlaces , assetId , asset , features , prefix , suffix , network ) ;
28922911}
2912+
2913+ /**
2914+ * Factory function for nep141 token instances.
2915+ *
2916+ * @param id uuid v4
2917+ * @param name unique identifier of the token
2918+ * @param fullName Complete human-readable name of the token
2919+ * @param decimalPlaces Number of decimal places this token supports (divisibility exponent)
2920+ * @param contractAddress Contract address of this token
2921+ * @param asset Asset which this coin represents. This is the same for both mainnet and testnet variants of a coin.
2922+ * @param features Features of this coin. Defaults to the DEFAULT_FEATURES defined in `AccountCoin`
2923+ * @param prefix Optional token prefix. Defaults to empty string
2924+ * @param suffix Optional token suffix. Defaults to token name.
2925+ * @param network Optional token network. Defaults to Near main network.
2926+ * @param primaryKeyCurve The elliptic curve for this chain/token
2927+ */
2928+ export function nep141Token (
2929+ id : string ,
2930+ name : string ,
2931+ fullName : string ,
2932+ decimalPlaces : number ,
2933+ contractAddress : string ,
2934+ asset : UnderlyingAsset ,
2935+ features : CoinFeature [ ] = AccountCoin . DEFAULT_FEATURES ,
2936+ prefix = '' ,
2937+ suffix : string = name . toUpperCase ( ) ,
2938+ network : AccountNetwork = Networks . main . near ,
2939+ primaryKeyCurve : KeyCurve = KeyCurve . Ed25519
2940+ ) {
2941+ return Object . freeze (
2942+ new Nep141Token ( {
2943+ id,
2944+ name,
2945+ fullName,
2946+ network,
2947+ decimalPlaces,
2948+ contractAddress,
2949+ prefix,
2950+ suffix,
2951+ features,
2952+ asset,
2953+ isToken : true ,
2954+ primaryKeyCurve,
2955+ baseUnit : BaseUnit . NEAR ,
2956+ } )
2957+ ) ;
2958+ }
2959+
2960+ /**
2961+ * Factory function for testnet nep141 token instances.
2962+ *
2963+ * @param id uuid v4
2964+ * @param name unique identifier of the token
2965+ * @param fullName Complete human-readable name of the token
2966+ * @param decimalPlaces Number of decimal places this token supports (divisibility exponent)
2967+ * @param contractAddress Contract address of this token
2968+ * @param asset Asset which this coin represents. This is the same for both mainnet and testnet variants of a coin.
2969+ * @param features Features of this coin. Defaults to the DEFAULT_FEATURES defined in `AccountCoin`
2970+ * @param prefix Optional token prefix. Defaults to empty string
2971+ * @param suffix Optional token suffix. Defaults to token name.
2972+ * @param network Optional token network. Defaults to the testnet Near network.
2973+ */
2974+ export function tnep141Token (
2975+ id : string ,
2976+ name : string ,
2977+ fullName : string ,
2978+ decimalPlaces : number ,
2979+ contractAddress : string ,
2980+ asset : UnderlyingAsset ,
2981+ features : CoinFeature [ ] = AccountCoin . DEFAULT_FEATURES ,
2982+ prefix = '' ,
2983+ suffix : string = name . toUpperCase ( ) ,
2984+ network : AccountNetwork = Networks . test . near
2985+ ) {
2986+ return nep141Token ( id , name , fullName , decimalPlaces , contractAddress , asset , features , prefix , suffix , network ) ;
2987+ }
0 commit comments