From 14f6e4683f703d8cdca0a05be9757e8b09025f44 Mon Sep 17 00:00:00 2001 From: foxytanuki Date: Wed, 27 Dec 2023 00:33:29 +0900 Subject: [PATCH 1/6] Add default to each networks --- proto/mycel/registry/network_name.proto | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/proto/mycel/registry/network_name.proto b/proto/mycel/registry/network_name.proto index e748ff82..76368474 100644 --- a/proto/mycel/registry/network_name.proto +++ b/proto/mycel/registry/network_name.proto @@ -11,6 +11,10 @@ enum NetworkName { // BTC 1xxx BITCOIN_MAINNET_MAINNET = 10000; BITCOIN_TESTNET_TESTNET = 10001; + // DEFAULT + BITCOIN_MAINNET_DEFAULT = 19998; + BITCOIN_TESTNET_DEFAULT = 19999; + // EVM 2xxxx // Etheruem @@ -42,6 +46,9 @@ enum NetworkName { // Zetachain // ZETA_MAINNET_MAINNET = 20018; ZETA_TESTNET_ATHENS = 20019; + // DEFAULT + EVM_MAINNET_DEFAULT = 29998; + EVM_TESTNET_DEFAULT = 29999; // MOVE 3xxxx //Aptos @@ -50,8 +57,15 @@ enum NetworkName { // Sui SUI_MAINNET_MAINNET = 30002; SUI_TESTNET_TESTNET = 30003; + // DEFAULT + MOVE_MAINNET_DEFAULT = 39998; + MOVE_TESTNET_DEFAULT = 39999; // SOLANA 4xxxx SOLANA_MAINNET_MAINNET = 40000; SOLANA_TESTNET_TESTNET = 40001; + // DEFAULT + SOLANA_MAINNET_DEFAULT = 49998; + SOLANA_TESTNET_DEFAULT = 49999; + } From 51f7654b5741b05fd3f37ea9d238094a92cd1aeb Mon Sep 17 00:00:00 2001 From: foxytanuki Date: Wed, 27 Dec 2023 18:34:06 +0900 Subject: [PATCH 2/6] Update default values --- proto/mycel/registry/network_name.proto | 13 ++-- x/registry/types/network_name.pb.go | 80 +++++++++++++++---------- 2 files changed, 53 insertions(+), 40 deletions(-) diff --git a/proto/mycel/registry/network_name.proto b/proto/mycel/registry/network_name.proto index 76368474..538e3fc2 100644 --- a/proto/mycel/registry/network_name.proto +++ b/proto/mycel/registry/network_name.proto @@ -12,9 +12,7 @@ enum NetworkName { BITCOIN_MAINNET_MAINNET = 10000; BITCOIN_TESTNET_TESTNET = 10001; // DEFAULT - BITCOIN_MAINNET_DEFAULT = 19998; - BITCOIN_TESTNET_DEFAULT = 19999; - + BITCOIN_DEFAULT_DEFAULT = 19999; // EVM 2xxxx // Etheruem @@ -47,8 +45,7 @@ enum NetworkName { // ZETA_MAINNET_MAINNET = 20018; ZETA_TESTNET_ATHENS = 20019; // DEFAULT - EVM_MAINNET_DEFAULT = 29998; - EVM_TESTNET_DEFAULT = 29999; + EVM_DEFAULT_DEFAULT = 29999; // MOVE 3xxxx //Aptos @@ -58,14 +55,12 @@ enum NetworkName { SUI_MAINNET_MAINNET = 30002; SUI_TESTNET_TESTNET = 30003; // DEFAULT - MOVE_MAINNET_DEFAULT = 39998; - MOVE_TESTNET_DEFAULT = 39999; + MOVE_DEFAULT_DEFAULT = 39999; // SOLANA 4xxxx SOLANA_MAINNET_MAINNET = 40000; SOLANA_TESTNET_TESTNET = 40001; // DEFAULT - SOLANA_MAINNET_DEFAULT = 49998; - SOLANA_TESTNET_DEFAULT = 49999; + SOLANA_DEFAULT_DEFAULT = 49999; } diff --git a/x/registry/types/network_name.pb.go b/x/registry/types/network_name.pb.go index 042de747..00f4e619 100644 --- a/x/registry/types/network_name.pb.go +++ b/x/registry/types/network_name.pb.go @@ -27,6 +27,8 @@ const ( // BTC 1xxx NetworkName_BITCOIN_MAINNET_MAINNET NetworkName = 10000 NetworkName_BITCOIN_TESTNET_TESTNET NetworkName = 10001 + // DEFAULT + NetworkName_BITCOIN_DEFAULT_DEFAULT NetworkName = 19999 // EVM 2xxxx // Etheruem NetworkName_ETHEREUM_MAINNET_MAINNET NetworkName = 20000 @@ -57,6 +59,8 @@ const ( // Zetachain // ZETA_MAINNET_MAINNET = 20018; NetworkName_ZETA_TESTNET_ATHENS NetworkName = 20019 + // DEFAULT + NetworkName_EVM_DEFAULT_DEFAULT NetworkName = 29999 // MOVE 3xxxx //Aptos NetworkName_APTOS_MAINNET_MAINNET NetworkName = 30000 @@ -64,15 +68,20 @@ const ( // Sui NetworkName_SUI_MAINNET_MAINNET NetworkName = 30002 NetworkName_SUI_TESTNET_TESTNET NetworkName = 30003 + // DEFAULT + NetworkName_MOVE_DEFAULT_DEFAULT NetworkName = 39999 // SOLANA 4xxxx NetworkName_SOLANA_MAINNET_MAINNET NetworkName = 40000 NetworkName_SOLANA_TESTNET_TESTNET NetworkName = 40001 + // DEFAULT + NetworkName_SOLANA_DEFAULT_DEFAULT NetworkName = 49999 ) var NetworkName_name = map[int32]string{ 0: "NO_NETWORK", 10000: "BITCOIN_MAINNET_MAINNET", 10001: "BITCOIN_TESTNET_TESTNET", + 19999: "BITCOIN_DEFAULT_DEFAULT", 20000: "ETHEREUM_MAINNET_MAINNET", 20001: "ETHEREUM_TESTNET_GOERLI", 20002: "ETHEREUM_TESTNET_SEPOLIA", @@ -90,18 +99,22 @@ var NetworkName_name = map[int32]string{ 20014: "ARBITRUM_TESTNET_GOERLI", 20017: "SHARDEUM_BETANET_SPHINX", 20019: "ZETA_TESTNET_ATHENS", + 29999: "EVM_DEFAULT_DEFAULT", 30000: "APTOS_MAINNET_MAINNET", 30001: "APTOS_TESTNET_TESTNET", 30002: "SUI_MAINNET_MAINNET", 30003: "SUI_TESTNET_TESTNET", + 39999: "MOVE_DEFAULT_DEFAULT", 40000: "SOLANA_MAINNET_MAINNET", 40001: "SOLANA_TESTNET_TESTNET", + 49999: "SOLANA_DEFAULT_DEFAULT", } var NetworkName_value = map[string]int32{ "NO_NETWORK": 0, "BITCOIN_MAINNET_MAINNET": 10000, "BITCOIN_TESTNET_TESTNET": 10001, + "BITCOIN_DEFAULT_DEFAULT": 19999, "ETHEREUM_MAINNET_MAINNET": 20000, "ETHEREUM_TESTNET_GOERLI": 20001, "ETHEREUM_TESTNET_SEPOLIA": 20002, @@ -119,12 +132,15 @@ var NetworkName_value = map[string]int32{ "ARBITRUM_TESTNET_GOERLI": 20014, "SHARDEUM_BETANET_SPHINX": 20017, "ZETA_TESTNET_ATHENS": 20019, + "EVM_DEFAULT_DEFAULT": 29999, "APTOS_MAINNET_MAINNET": 30000, "APTOS_TESTNET_TESTNET": 30001, "SUI_MAINNET_MAINNET": 30002, "SUI_TESTNET_TESTNET": 30003, + "MOVE_DEFAULT_DEFAULT": 39999, "SOLANA_MAINNET_MAINNET": 40000, "SOLANA_TESTNET_TESTNET": 40001, + "SOLANA_DEFAULT_DEFAULT": 49999, } func (x NetworkName) String() string { @@ -142,35 +158,37 @@ func init() { func init() { proto.RegisterFile("mycel/registry/network_name.proto", fileDescriptor_9c4aafa085c4431e) } var fileDescriptor_9c4aafa085c4431e = []byte{ - // 473 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x6c, 0x93, 0x3d, 0x6f, 0xd3, 0x40, - 0x18, 0xc7, 0xe3, 0x0e, 0x1d, 0x0e, 0xa9, 0x3a, 0x19, 0x41, 0x41, 0x14, 0x4b, 0xac, 0x48, 0x24, - 0x03, 0x9f, 0xe0, 0xec, 0x1e, 0xf1, 0x81, 0xfd, 0x9c, 0xe5, 0xbb, 0xf0, 0xd2, 0x25, 0x4a, 0x8b, - 0x55, 0x22, 0x70, 0x5c, 0xa5, 0x46, 0x90, 0x6f, 0xc0, 0x58, 0x76, 0x0f, 0xbc, 0xbf, 0x83, 0x28, - 0x5d, 0x3a, 0xc2, 0xc6, 0xd8, 0x91, 0x11, 0x25, 0x5b, 0x3e, 0x05, 0x8a, 0x2f, 0xe7, 0x04, 0x5f, - 0x27, 0xcb, 0xfa, 0xdd, 0xef, 0xee, 0x79, 0xfe, 0x8f, 0x1e, 0x74, 0x25, 0x1d, 0xed, 0x24, 0x8f, - 0x5a, 0xc3, 0x64, 0xb7, 0xbf, 0x9f, 0x0f, 0x47, 0xad, 0x41, 0x92, 0x3f, 0xc9,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 0x00, 0x00, + // 510 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x6c, 0x93, 0x4d, 0x6f, 0xd3, 0x3e, + 0x1c, 0xc7, 0x9b, 0xff, 0x5f, 0xda, 0xc1, 0x48, 0x93, 0x15, 0x9e, 0x61, 0x44, 0xe2, 0x8a, 0x44, + 0x7b, 0xe0, 0x15, 0x38, 0xa9, 0xd7, 0x18, 0x12, 0x3b, 0x8a, 0x9d, 0x02, 0xbb, 0x54, 0xdd, 0x88, + 0x46, 0x05, 0x69, 0xa6, 0x2e, 0x08, 0xfa, 0x06, 0x38, 0x8f, 0x7b, 0x24, 0x9e, 0x9f, 0x1f, 0xc7, + 0x2e, 0xdc, 0x80, 0x1b, 0x37, 0x76, 0xe4, 0x88, 0xda, 0x5b, 0x5f, 0x03, 0x07, 0xd4, 0xb8, 0x4e, + 0xb6, 0x98, 0x93, 0x15, 0x7d, 0xfc, 0xf9, 0xfa, 0xe7, 0xdf, 0x2f, 0x06, 0xe7, 0x93, 0xf1, 0x46, + 0x7c, 0xbb, 0x35, 0x8a, 0x37, 0x07, 0xdb, 0xd9, 0x68, 0xdc, 0x1a, 0xc6, 0xd9, 0xdd, 0x74, 0x74, + 0xab, 0x37, 0xec, 0x27, 0x71, 0x73, 0x6b, 0x94, 0x66, 0xa9, 0xb9, 0x5c, 0x6c, 0x69, 0xaa, 0x2d, + 0x17, 0xfe, 0x2c, 0x81, 0x23, 0x54, 0x6e, 0xa3, 0xfd, 0x24, 0x36, 0x97, 0x01, 0xa0, 0xac, 0x47, + 0xb1, 0xb8, 0xca, 0xc2, 0x2b, 0xb0, 0x61, 0xae, 0x80, 0x93, 0x36, 0x11, 0x0e, 0x23, 0xb4, 0xe7, + 0x23, 0x42, 0x29, 0x16, 0x6a, 0x85, 0x3b, 0xf4, 0x20, 0x15, 0x98, 0x8b, 0x39, 0x5d, 0xac, 0xf0, + 0x01, 0x35,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, 0x2c, 0x50, 0x69, 0x22, 0xe1, 0x62, 0xca, + 0xe1, 0x9e, 0x44, 0xb8, 0xeb, 0x6b, 0x7f, 0xc7, 0xc7, 0x59, 0x71, 0x5f, 0x14, 0x08, 0xa6, 0x37, + 0xe3, 0xd3, 0x41, 0x58, 0x9f, 0xc2, 0xee, 0xac, 0x08, 0xe5, 0x11, 0xd1, 0xbc, 0xcf, 0x15, 0xaa, + 0x5b, 0x7b, 0x33, 0xc3, 0x3c, 0x03, 0x8e, 0xf9, 0xac, 0x8b, 0xb5, 0x5a, 0xbe, 0x7e, 0xf9, 0x6f, + 0x3e, 0x19, 0xce, 0x3c, 0x44, 0x91, 0x16, 0xfa, 0xed, 0x10, 0xad, 0xe7, 0x7e, 0x3f, 0x44, 0xeb, + 0xc9, 0x3f, 0xef, 0xff, 0x6f, 0xbb, 0x3f, 0x26, 0x96, 0xb1, 0x3f, 0xb1, 0x8c, 0xdf, 0x13, 0xcb, + 0xd8, 0x99, 0x5a, 0x8d, 0xfd, 0xa9, 0xd5, 0xf8, 0x35, 0xb5, 0x1a, 0x6b, 0xcd, 0xcd, 0x41, 0x76, + 0xf3, 0xce, 0x7a, 0x73, 0x23, 0x4d, 0x5a, 0xc5, 0x9b, 0xbd, 0x78, 0x23, 0x4d, 0xfa, 0x83, 0xa1, + 0xfc, 0x68, 0xdd, 0xab, 0x5e, 0x79, 0x36, 0xde, 0x8a, 0xb7, 0xd7, 0x97, 0x8a, 0xf7, 0x7d, 0xe9, + 0x6f, 0x00, 0x00, 0x00, 0xff, 0xff, 0x10, 0xa8, 0x45, 0x66, 0x04, 0x04, 0x00, 0x00, } From e3c5eedcfe33999d2df619f5e49c8c6b0090499b Mon Sep 17 00:00:00 2001 From: foxytanuki Date: Wed, 27 Dec 2023 19:17:31 +0900 Subject: [PATCH 3/6] Add default wallet record type retrieval --- x/registry/types/secend_level_domain.go | 25 +++++++++++++++++++--- x/registry/types/wallet_record.go | 28 +++++++++++++++++++++++++ 2 files changed, 50 insertions(+), 3 deletions(-) diff --git a/x/registry/types/secend_level_domain.go b/x/registry/types/secend_level_domain.go index 19b7a118..f33bec27 100644 --- a/x/registry/types/secend_level_domain.go +++ b/x/registry/types/secend_level_domain.go @@ -20,12 +20,31 @@ func (secondLevelDomain SecondLevelDomain) ParseParent() (parent string) { } func (secondLevelDomain *SecondLevelDomain) GetWalletRecord(walletRecordType string) string { + var defaultWalletRecordValue string + defaultWalletRecordType := GetDefaultWalletRecordType(walletRecordType) + + // Validate walletRecordType + err := ValidateWalletRecordType(walletRecordType) + if err != nil { + return "" + } + for _, rec := range secondLevelDomain.Records { - if rec.GetWalletRecord() != nil && rec.GetWalletRecord().WalletRecordType.String() == walletRecordType { - return rec.GetWalletRecord().Value + walletRecord := rec.GetWalletRecord() + if walletRecord != nil { + // Get default wallet record value + if walletRecord.WalletRecordType.String() == defaultWalletRecordType { + defaultWalletRecordValue = walletRecord.Value + } + // Get wallet record value + if walletRecord.WalletRecordType.String() == walletRecordType && walletRecord.Value != "" { + // Return wallet record value if found + return walletRecord.Value + } } } - return "" + // Return default wallet record value if no wallet record is found + return defaultWalletRecordValue } func (secondLevelDomain *SecondLevelDomain) GetDnsRecord(dnsRecordType string) string { diff --git a/x/registry/types/wallet_record.go b/x/registry/types/wallet_record.go index 51233037..dd9b2fec 100644 --- a/x/registry/types/wallet_record.go +++ b/x/registry/types/wallet_record.go @@ -15,6 +15,8 @@ func WalletRecordFormats() map[string]string { // Bitcoin "BITCOIN_MAINNET_MAINNET": "BITCOIN", "BITCOIN_TESTNET_TESTNET": "BITCOIN", + // DEFAULT + "BITCOIN_DEFAULT_DEFAULT": "BITCOIN", // EVM "ETHEREUM_MAINNET_MAINNET": "ETHEREUM", @@ -42,16 +44,22 @@ func WalletRecordFormats() map[string]string { "SHARDEUM_BETANET_SPHINX": "ETHEREUM", // ZetaChain "ZETA_TESTNET_ATHENS": "ETHEREUM", + // DEFAULT + "EVM_DEFAULT_DEFAULT": "ETHEREUM", // Move "APTOS_MAINNET_MAINNET": "MOVE", "APTOS_TESTNET_TESTNET": "MOVE", "SUI_MAINNET_MAINNET": "MOVE", "SUI_TESTNET_TESTNET": "MOVE", + // DEFAULT + "MOVE_DEFAULT_DEFAULT": "MOVE", // Solana "SOLANA_MAINNET_MAINNET": "SOLANA", "SOLANA_TESTNET_TESTNET": "SOLANA", + // DEFAULT + "SOLANA_DEFAULT_DEFAULT": "SOLANA", } } @@ -97,3 +105,23 @@ func ValidateWalletAddress(walletAddressFormat string, address string) (err erro } return err } + +// GetDefaultRecordType(walletRecordType) returns the default wallet address for a given wallet record type. +// This is used when a wallet record is not found in the domain record. +func GetDefaultWalletRecordType(walletRecordType string) string { + wrf := WalletRecordFormats() + network := wrf[walletRecordType] + switch network { + case "BITCOIN": + return "BITCOIN_DEFAULT_DEFAULT" + case "ETHEREUM": + return "EVM_DEFAULT_DEFAULT" + case "MOVE": + return "MOVE_DEFAULT_DEFAULT" + case "SOLANA": + return "SOLANA_DEFAULT_DEFAULT" + default: + // This should never happen + panic(fmt.Sprintf("Wallet record type %s is not found in WalletRecordFormats", walletRecordType)) + } +} From 32e0a4d8243c6cce052ae082356fda420797a11a Mon Sep 17 00:00:00 2001 From: foxytanuki Date: Wed, 27 Dec 2023 19:18:14 +0900 Subject: [PATCH 4/6] Fix file name x/registry/types/second_level_domain.go --- .../types/{secend_level_domain.go => second_level_domain.go} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename x/registry/types/{secend_level_domain.go => second_level_domain.go} (100%) diff --git a/x/registry/types/secend_level_domain.go b/x/registry/types/second_level_domain.go similarity index 100% rename from x/registry/types/secend_level_domain.go rename to x/registry/types/second_level_domain.go From 3c8d89483596446db6613870f848a0ad279175a5 Mon Sep 17 00:00:00 2001 From: foxytanuki Date: Wed, 27 Dec 2023 20:09:36 +0900 Subject: [PATCH 5/6] Add TestGetWalletRecord --- x/registry/types/second_level_domain_test.go | 39 ++++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/x/registry/types/second_level_domain_test.go b/x/registry/types/second_level_domain_test.go index 5e96f61e..b03e1881 100644 --- a/x/registry/types/second_level_domain_test.go +++ b/x/registry/types/second_level_domain_test.go @@ -92,6 +92,45 @@ func TestDomainValidate(t *testing.T) { } } +func TestGetWalletRecord(t *testing.T) { + domain := SecondLevelDomain{Name: "foo", Parent: "myc"} + testCases := []struct { + desc string + walletRecordType string + resp string + fn func() + }{ + // BITCOIN + {desc: "Bitcoin Mainnet", walletRecordType: "BITCOIN_MAINNET_MAINNET", resp: "1BvBMSEYstWetqTFn5Au4m4GFg7xJaNVN2", fn: func() { + err := domain.UpdateWalletRecord("BITCOIN_DEFAULT_DEFAULT", "1BvBMSEYstWetqTFn5Au4m4GFg7xJaNVN2") + require.Nil(t, err) + }}, + // EVM + {desc: "Ethereum Mainnet", walletRecordType: "ETHEREUM_MAINNET_MAINNET", resp: "0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266", fn: func() { + err := domain.UpdateWalletRecord("EVM_DEFAULT_DEFAULT", "0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266") + require.Nil(t, err) + }}, + // MOVE + {desc: "Aptos Mainnet", walletRecordType: "APTOS_MAINNET_MAINNET", resp: "0xeeff357ea5c1a4e7bc11b2b17ff2dc2dcca69750bfef1e1ebcaccf8c8018175b", fn: func() { + err := domain.UpdateWalletRecord("MOVE_DEFAULT_DEFAULT", "0xeeff357ea5c1a4e7bc11b2b17ff2dc2dcca69750bfef1e1ebcaccf8c8018175b") + require.Nil(t, err) + }}, + // SOLANA + {desc: "Solana Mainnet", walletRecordType: "SOLANA_MAINNET_MAINNET", resp: "HN7cABqLq46Es1jh92dQQisAq662SmxELLLsHHe4YWrH", fn: func() { + err := domain.UpdateWalletRecord("SOLANA_DEFAULT_DEFAULT", "HN7cABqLq46Es1jh92dQQisAq662SmxELLLsHHe4YWrH") + require.Nil(t, err) + }}, + } + + for _, tc := range testCases { + t.Run(tc.desc, func(t *testing.T) { + tc.fn() + rec := domain.GetWalletRecord(tc.walletRecordType) + require.Equal(t, tc.resp, rec) + }) + } +} + func TestDomainUpdateWalletRecord(t *testing.T) { testCases := []struct { walletRecordType string From d0419f2b0af851e60edd086793287566c5e87794 Mon Sep 17 00:00:00 2001 From: foxytanuki Date: Thu, 11 Jan 2024 19:52:04 +0900 Subject: [PATCH 6/6] Add test cases to TestGetWalletRecord --- x/registry/types/second_level_domain_test.go | 24 ++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/x/registry/types/second_level_domain_test.go b/x/registry/types/second_level_domain_test.go index b03e1881..89a42bab 100644 --- a/x/registry/types/second_level_domain_test.go +++ b/x/registry/types/second_level_domain_test.go @@ -101,25 +101,41 @@ func TestGetWalletRecord(t *testing.T) { fn func() }{ // BITCOIN - {desc: "Bitcoin Mainnet", walletRecordType: "BITCOIN_MAINNET_MAINNET", resp: "1BvBMSEYstWetqTFn5Au4m4GFg7xJaNVN2", fn: func() { + {desc: "Bitcoin Default", walletRecordType: "BITCOIN_MAINNET_MAINNET", resp: "1BvBMSEYstWetqTFn5Au4m4GFg7xJaNVN2", fn: func() { err := domain.UpdateWalletRecord("BITCOIN_DEFAULT_DEFAULT", "1BvBMSEYstWetqTFn5Au4m4GFg7xJaNVN2") require.Nil(t, err) }}, + {desc: "Bitcoin Mainnet", walletRecordType: "BITCOIN_MAINNET_MAINNET", resp: "1BvBMSEYstWetqTFn5Au4m4GFg7xJaNVN2", fn: func() { + err := domain.UpdateWalletRecord("BITCOIN_MAINNET_MAINNET", "1BvBMSEYstWetqTFn5Au4m4GFg7xJaNVN2") + require.Nil(t, err) + }}, // EVM - {desc: "Ethereum Mainnet", walletRecordType: "ETHEREUM_MAINNET_MAINNET", resp: "0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266", fn: func() { + {desc: "Ethereum Default", walletRecordType: "ETHEREUM_MAINNET_MAINNET", resp: "0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266", fn: func() { err := domain.UpdateWalletRecord("EVM_DEFAULT_DEFAULT", "0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266") require.Nil(t, err) }}, + {desc: "Ethereum Mainnet", walletRecordType: "ETHEREUM_MAINNET_MAINNET", resp: "0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266", fn: func() { + err := domain.UpdateWalletRecord("ETHEREUM_MAINNET_MAINNET", "0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266") + require.Nil(t, err) + }}, // MOVE - {desc: "Aptos Mainnet", walletRecordType: "APTOS_MAINNET_MAINNET", resp: "0xeeff357ea5c1a4e7bc11b2b17ff2dc2dcca69750bfef1e1ebcaccf8c8018175b", fn: func() { + {desc: "Aptos Default", walletRecordType: "APTOS_MAINNET_MAINNET", resp: "0xeeff357ea5c1a4e7bc11b2b17ff2dc2dcca69750bfef1e1ebcaccf8c8018175b", fn: func() { err := domain.UpdateWalletRecord("MOVE_DEFAULT_DEFAULT", "0xeeff357ea5c1a4e7bc11b2b17ff2dc2dcca69750bfef1e1ebcaccf8c8018175b") require.Nil(t, err) }}, + {desc: "Aptos Mainnet", walletRecordType: "APTOS_MAINNET_MAINNET", resp: "0xeeff357ea5c1a4e7bc11b2b17ff2dc2dcca69750bfef1e1ebcaccf8c8018175b", fn: func() { + err := domain.UpdateWalletRecord("APTOS_MAINNET_MAINNET", "0xeeff357ea5c1a4e7bc11b2b17ff2dc2dcca69750bfef1e1ebcaccf8c8018175b") + require.Nil(t, err) + }}, // SOLANA - {desc: "Solana Mainnet", walletRecordType: "SOLANA_MAINNET_MAINNET", resp: "HN7cABqLq46Es1jh92dQQisAq662SmxELLLsHHe4YWrH", fn: func() { + {desc: "Solana Default", walletRecordType: "SOLANA_MAINNET_MAINNET", resp: "HN7cABqLq46Es1jh92dQQisAq662SmxELLLsHHe4YWrH", fn: func() { err := domain.UpdateWalletRecord("SOLANA_DEFAULT_DEFAULT", "HN7cABqLq46Es1jh92dQQisAq662SmxELLLsHHe4YWrH") require.Nil(t, err) }}, + {desc: "Solana Mainnet", walletRecordType: "SOLANA_MAINNET_MAINNET", resp: "HN7cABqLq46Es1jh92dQQisAq662SmxELLLsHHe4YWrH", fn: func() { + err := domain.UpdateWalletRecord("SOLANA_MAINNET_MAINNET", "HN7cABqLq46Es1jh92dQQisAq662SmxELLLsHHe4YWrH") + require.Nil(t, err) + }}, } for _, tc := range testCases {