Skip to content

Commit db3138d

Browse files
authored
chore: adding tNEAR for near-testnet (#958)
1 parent fa4617a commit db3138d

File tree

4 files changed

+33
-9
lines changed

4 files changed

+33
-9
lines changed

packages/advanced-logic/test/extensions/payment-network/native-token.test.ts

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,16 @@ describe('extensions/payment-network/native-token', () => {
2121
value: 'NEAR',
2222
network: 'aurora',
2323
};
24-
const nearTestnetCurrency = {
24+
const auroraTestnetCurrency = {
2525
type: RequestLogicTypes.CURRENCY.ETH,
2626
value: 'NEAR-testnet',
2727
network: 'aurora-testnet',
2828
};
29+
const nearTestnetCurrency = {
30+
type: RequestLogicTypes.CURRENCY.ETH,
31+
value: 'tNEAR',
32+
network: 'near-testnet',
33+
};
2934
const nativeTokenTestCases = [
3035
{
3136
name: 'Near',
@@ -34,14 +39,23 @@ describe('extensions/payment-network/native-token', () => {
3439
suffix: 'near',
3540
wrongSuffix: 'testnet',
3641
currency: nearCurrency,
37-
wrongCurrency: nearTestnetCurrency,
42+
wrongCurrency: auroraTestnetCurrency,
3843
},
3944
{
40-
name: 'Near testnet',
45+
name: 'Aurora testnet',
4146
paymentNetwork: new NearNativePaymentNetwork() as NativeTokenPaymentNetwork,
4247
networkName: 'aurora-testnet',
4348
suffix: 'testnet',
4449
wrongSuffix: 'near',
50+
currency: auroraTestnetCurrency,
51+
wrongCurrency: nearCurrency,
52+
},
53+
{
54+
name: 'Near testnet',
55+
paymentNetwork: new NearNativePaymentNetwork() as NativeTokenPaymentNetwork,
56+
networkName: 'near-testnet',
57+
suffix: 'testnet',
58+
wrongSuffix: 'near',
4559
currency: nearTestnetCurrency,
4660
wrongCurrency: nearCurrency,
4761
},

packages/currency/src/currencyManager.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -237,6 +237,7 @@ export class CurrencyManager<TMeta = unknown> implements ICurrencyManager<TMeta>
237237
switch (currency.symbol) {
238238
case 'NEAR':
239239
case 'NEAR-testnet':
240+
case 'tNEAR':
240241
return isValidNearAddress(address, currency.network);
241242
default:
242243
// we don't pass a third argument to the validate method here

packages/currency/src/native.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -57,12 +57,6 @@ export const nativeCurrencies: Record<NativeCurrencyType, (NativeCurrency & { na
5757
name: 'Fantom',
5858
network: 'fantom',
5959
},
60-
{
61-
symbol: 'BNB',
62-
decimals: 18,
63-
name: 'BNB',
64-
network: 'bsctest',
65-
},
6660
{
6761
symbol: 'BNB',
6862
decimals: 18,
@@ -81,6 +75,12 @@ export const nativeCurrencies: Record<NativeCurrencyType, (NativeCurrency & { na
8175
name: 'Near Testnet',
8276
network: 'aurora-testnet',
8377
},
78+
{
79+
symbol: 'tNEAR',
80+
decimals: 24,
81+
name: 'Test Near',
82+
network: 'near-testnet',
83+
},
8484
{
8585
symbol: 'ARETH',
8686
decimals: 18,

packages/currency/test/currencyManager.test.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -456,6 +456,7 @@ describe('CurrencyManager', () => {
456456
const nearAddresses: Record<string, string> = {
457457
aurora: 'requestnetwork.near',
458458
'aurora-testnet': 'requestnetwork.testnet',
459+
'near-testnet': 'requestnetwork.testnet',
459460
};
460461

461462
const eip55Addresses: string[] = [
@@ -489,6 +490,13 @@ describe('CurrencyManager', () => {
489490
network: 'aurora-testnet',
490491
},
491492
},
493+
near: {
494+
tNEAR: {
495+
type: RequestLogicTypes.CURRENCY.ETH,
496+
symbol: 'tNEAR',
497+
network: 'near-testnet',
498+
},
499+
},
492500
};
493501

494502
const testValidateAddressForCurrency = (
@@ -520,6 +528,7 @@ describe('CurrencyManager', () => {
520528
switch (currency.symbol) {
521529
case 'NEAR':
522530
case 'NEAR-testnet':
531+
case 'tNEAR':
523532
testValidateAddressForCurrency(nearAddresses[currency.network], currency);
524533
break;
525534
default:

0 commit comments

Comments
 (0)