@@ -132,6 +132,10 @@ export interface Sip10TokenConstructorOptions extends AccountConstructorOptions
132132 assetId : string ;
133133}
134134
135+ export interface Nep141TokenConstructorOptions extends AccountConstructorOptions {
136+ contractAddress : string ;
137+ }
138+
135139export interface ContractAddress extends String {
136140 __contractaddress_phantom__ : never ;
137141}
@@ -568,6 +572,21 @@ export class Sip10Token extends AccountCoinToken {
568572 }
569573}
570574
575+ /**
576+ * The Near network supports tokens
577+ * Near tokens work similar to native near coin
578+ */
579+ export class Nep141Token extends AccountCoinToken {
580+ public contractAddress : string ;
581+ constructor ( options : Nep141TokenConstructorOptions ) {
582+ super ( {
583+ ...options ,
584+ } ) ;
585+
586+ this . contractAddress = options . contractAddress ;
587+ }
588+ }
589+
571590/**
572591 * Factory function for account coin instances.
573592 *
@@ -2880,3 +2899,79 @@ export function tsip10Token(
28802899) {
28812900 return sip10Token ( id , name , fullName , decimalPlaces , assetId , asset , features , prefix , suffix , network ) ;
28822901}
2902+
2903+ /**
2904+ * Factory function for nep141 token instances.
2905+ *
2906+ * @param id uuid v4
2907+ * @param name unique identifier of the token
2908+ * @param fullName Complete human-readable name of the token
2909+ * @param decimalPlaces Number of decimal places this token supports (divisibility exponent)
2910+ * @param contractAddress Contract address of this token
2911+ * @param asset Asset which this coin represents. This is the same for both mainnet and testnet variants of a coin.
2912+ * @param features Features of this coin. Defaults to the DEFAULT_FEATURES defined in `AccountCoin`
2913+ * @param prefix Optional token prefix. Defaults to empty string
2914+ * @param suffix Optional token suffix. Defaults to token name.
2915+ * @param network Optional token network. Defaults to Near main network.
2916+ * @param primaryKeyCurve The elliptic curve for this chain/token
2917+ */
2918+ export function nep141Token (
2919+ id : string ,
2920+ name : string ,
2921+ fullName : string ,
2922+ decimalPlaces : number ,
2923+ contractAddress : string ,
2924+ asset : UnderlyingAsset ,
2925+ features : CoinFeature [ ] = AccountCoin . DEFAULT_FEATURES ,
2926+ prefix = '' ,
2927+ suffix : string = name . toUpperCase ( ) ,
2928+ network : AccountNetwork = Networks . main . near ,
2929+ primaryKeyCurve : KeyCurve = KeyCurve . Ed25519
2930+ ) {
2931+ return Object . freeze (
2932+ new Nep141Token ( {
2933+ id,
2934+ name,
2935+ fullName,
2936+ network,
2937+ decimalPlaces,
2938+ contractAddress,
2939+ prefix,
2940+ suffix,
2941+ features,
2942+ asset,
2943+ isToken : true ,
2944+ primaryKeyCurve,
2945+ baseUnit : BaseUnit . NEAR ,
2946+ } )
2947+ ) ;
2948+ }
2949+
2950+ /**
2951+ * Factory function for testnet nep141 token instances.
2952+ *
2953+ * @param id uuid v4
2954+ * @param name unique identifier of the token
2955+ * @param fullName Complete human-readable name of the token
2956+ * @param decimalPlaces Number of decimal places this token supports (divisibility exponent)
2957+ * @param contractAddress Contract address of this token
2958+ * @param asset Asset which this coin represents. This is the same for both mainnet and testnet variants of a coin.
2959+ * @param features Features of this coin. Defaults to the DEFAULT_FEATURES defined in `AccountCoin`
2960+ * @param prefix Optional token prefix. Defaults to empty string
2961+ * @param suffix Optional token suffix. Defaults to token name.
2962+ * @param network Optional token network. Defaults to the testnet Near network.
2963+ */
2964+ export function tnep141Token (
2965+ id : string ,
2966+ name : string ,
2967+ fullName : string ,
2968+ decimalPlaces : number ,
2969+ contractAddress : string ,
2970+ asset : UnderlyingAsset ,
2971+ features : CoinFeature [ ] = AccountCoin . DEFAULT_FEATURES ,
2972+ prefix = '' ,
2973+ suffix : string = name . toUpperCase ( ) ,
2974+ network : AccountNetwork = Networks . test . near
2975+ ) {
2976+ return nep141Token ( id , name , fullName , decimalPlaces , contractAddress , asset , features , prefix , suffix , network ) ;
2977+ }
0 commit comments