From 66fa85c70a0bb4040e8aa08e5efaf4f32a7b57f6 Mon Sep 17 00:00:00 2001 From: Michael Vandeberg Date: Fri, 29 Nov 2024 15:47:47 -0700 Subject: [PATCH] #26: Update nickname ABI and correctly resolve nickname --- abis/nicknames.json | 432 +++++++++++++++++++++++++++++------------- services/nicknames.ts | 9 + utils/addresses.ts | 10 +- 3 files changed, 319 insertions(+), 132 deletions(-) diff --git a/abis/nicknames.json b/abis/nicknames.json index b6d2177..a4fd1e6 100644 --- a/abis/nicknames.json +++ b/abis/nicknames.json @@ -5,26 +5,17 @@ "return": "common.str", "description": "Verify if a new name is valid", "entry_point": 1523793306, - "entry-point": "0x5ad33d9a", - "read_only": true, - "read-only": true - }, - "get_community_tokens": { - "argument": "nft.get_tokens_args", - "return": "nft.token_ids", - "description": "Get community tokens", - "entry_point": 1237153485, - "entry-point": "0x49bd76cd", "read_only": true, + "entry-point": "0x5ad33d9a", "read-only": true }, "get_tabi": { "argument": "nft.token", - "return": "nicknames.tabi", + "return": "nicknames.get_tabi_result", "description": "Get TABI", "entry_point": 1698453016, - "entry-point": "0x653c5618", "read_only": true, + "entry-point": "0x653c5618", "read-only": true }, "get_main_token": { @@ -32,8 +23,44 @@ "return": "nft.token", "description": "Get main token of an account", "entry_point": 1053665215, + "read_only": true, "entry-point": "0x3ecda7bf", + "read-only": true + }, + "get_extended_metadata": { + "argument": "nft.token", + "return": "nicknames.extended_metadata", + "description": "Get extended metadata", + "entry_point": 52933493, "read_only": true, + "entry-point": "0x0327b375", + "read-only": true + }, + "get_address_by_token_id": { + "argument": "nft.token", + "return": "nicknames.address_data", + "description": "Resolve the address of a nickname by providing the token id", + "entry_point": 492743805, + "read_only": true, + "entry-point": "0x1d5eac7d", + "read-only": true + }, + "get_address": { + "argument": "common.str", + "return": "nicknames.address_data", + "description": "Resolve the address of a nickname", + "entry_point": 2786780648, + "read_only": true, + "entry-point": "0xa61ae5e8", + "read-only": true + }, + "get_tokens_by_address": { + "argument": "nicknames.get_tokens_by_address_args", + "return": "nft.token_ids", + "description": "Get tokens owned by an address", + "entry_point": 1617918091, + "read_only": true, + "entry-point": "0x606f788b", "read-only": true }, "mint": { @@ -41,8 +68,8 @@ "return": "", "description": "Create new name", "entry_point": 3698268091, - "entry-point": "0xdc6f17bb", "read_only": false, + "entry-point": "0xdc6f17bb", "read-only": false }, "burn": { @@ -50,8 +77,8 @@ "return": "", "description": "Delete a name", "entry_point": 2241834181, - "entry-point": "0x859facc5", "read_only": false, + "entry-point": "0x859facc5", "read-only": false }, "transfer": { @@ -59,17 +86,8 @@ "return": "", "description": "Transfer Name", "entry_point": 670398154, - "entry-point": "0x27f576ca", - "read_only": false, - "read-only": false - }, - "transfer_to_community": { - "argument": "nft.transfer_args", - "return": "", - "description": "Transfer name to another address and define that the name will be controlled by the community", - "entry_point": 2789495215, - "entry-point": "0xa64451af", "read_only": false, + "entry-point": "0x27f576ca", "read-only": false }, "set_tabi": { @@ -77,8 +95,8 @@ "return": "", "description": "Set Text ABI for a token", "entry_point": 2998339941, - "entry-point": "0xb2b70965", "read_only": false, + "entry-point": "0xb2b70965", "read-only": false }, "set_metadata": { @@ -86,8 +104,8 @@ "return": "", "description": "Set metadata", "entry_point": 1029287705, - "entry-point": "0x3d59af19", "read_only": false, + "entry-point": "0x3d59af19", "read-only": false }, "set_main_token": { @@ -95,8 +113,26 @@ "return": "", "description": "Set main token", "entry_point": 191552998, + "read_only": false, "entry-point": "0x0b6adde6", + "read-only": false + }, + "set_address": { + "argument": "nicknames.set_address_args", + "return": "", + "description": "Set address", + "entry_point": 1560272691, + "read_only": false, + "entry-point": "0x5cffdf33", + "read-only": false + }, + "set_extended_metadata": { + "argument": "nicknames.set_extended_metadata_args", + "return": "", + "description": "Set extended metadata (including the address to which the name resolves)", + "entry_point": 4010970275, "read_only": false, + "entry-point": "0xef128ca3", "read-only": false }, "name": { @@ -104,8 +140,8 @@ "return": "common.str", "description": "Get name of the NFT", "entry_point": 2191741823, - "entry-point": "0x82a3537f", "read_only": true, + "entry-point": "0x82a3537f", "read-only": true }, "symbol": { @@ -113,8 +149,8 @@ "return": "common.str", "description": "Get the symbol of the NFT", "entry_point": 3077209249, - "entry-point": "0xb76a7ca1", "read_only": true, + "entry-point": "0xb76a7ca1", "read-only": true }, "uri": { @@ -122,8 +158,8 @@ "return": "common.str", "description": "Get URI of the NFT", "entry_point": 1894111158, - "entry-point": "0x70e5d7b6", "read_only": true, + "entry-point": "0x70e5d7b6", "read-only": true }, "get_info": { @@ -131,8 +167,17 @@ "return": "nft.info", "description": "Get name, symbol and decimals", "entry_point": 3179243600, + "read_only": true, "entry-point": "0xbd7f6850", + "read-only": true + }, + "owner": { + "argument": "", + "return": "common.address", + "description": "Get the owner of the collection", + "entry_point": 1276127593, "read_only": true, + "entry-point": "0x4c102969", "read-only": true }, "total_supply": { @@ -140,8 +185,8 @@ "return": "common.uint64", "description": "Get total supply", "entry_point": 2967091508, - "entry-point": "0xb0da3934", "read_only": true, + "entry-point": "0xb0da3934", "read-only": true }, "royalties": { @@ -149,8 +194,8 @@ "return": "nft.royalties", "description": "Get royalties", "entry_point": 921242832, - "entry-point": "0x36e90cd0", "read_only": true, + "entry-point": "0x36e90cd0", "read-only": true }, "balance_of": { @@ -158,8 +203,8 @@ "return": "common.uint64", "description": "Get balance of an account", "entry_point": 1550980247, - "entry-point": "0x5c721497", "read_only": true, + "entry-point": "0x5c721497", "read-only": true }, "owner_of": { @@ -167,8 +212,8 @@ "return": "common.address", "description": "Get the owner of a token", "entry_point": 3982608455, - "entry-point": "0xed61c847", "read_only": true, + "entry-point": "0xed61c847", "read-only": true }, "metadata_of": { @@ -176,8 +221,8 @@ "return": "common.str", "description": "Get the metadata of a token", "entry_point": 392990591, - "entry-point": "0x176c8f7f", "read_only": true, + "entry-point": "0x176c8f7f", "read-only": true }, "get_tokens": { @@ -185,8 +230,8 @@ "return": "nft.token_ids", "description": "Get list of token IDs", "entry_point": 2103140055, - "entry-point": "0x7d5b5ed7", "read_only": true, + "entry-point": "0x7d5b5ed7", "read-only": true }, "get_tokens_by_owner": { @@ -194,8 +239,8 @@ "return": "nft.token_ids", "description": "Get tokens owned by an address", "entry_point": 4229163893, - "entry-point": "0xfc13eb75", "read_only": true, + "entry-point": "0xfc13eb75", "read-only": true }, "get_approved": { @@ -203,8 +248,8 @@ "return": "common.address", "description": "Check if an account is approved to operate a token ID", "entry_point": 1282609184, - "entry-point": "0x4c731020", "read_only": true, + "entry-point": "0x4c731020", "read-only": true }, "is_approved_for_all": { @@ -212,8 +257,8 @@ "return": "common.boole", "description": "Check if an account is approved to operate all tokens owned by other account", "entry_point": 3886779621, - "entry-point": "0xe7ab8ce5", "read_only": true, + "entry-point": "0xe7ab8ce5", "read-only": true }, "get_operator_approvals": { @@ -221,17 +266,26 @@ "return": "nft.get_operators_return", "description": "Get allowances of an account", "entry_point": 3676042766, - "entry-point": "0xdb1bf60e", "read_only": true, + "entry-point": "0xdb1bf60e", "read-only": true }, + "transfer_ownership": { + "argument": "common.address", + "return": "", + "description": "Transfer ownership of the collection", + "entry_point": 961275650, + "read_only": false, + "entry-point": "0x394be702", + "read-only": false + }, "set_royalties": { "argument": "nft.royalties", "return": "", "description": "Set royalties", "entry_point": 995865963, - "entry-point": "0x3b5bb56b", "read_only": false, + "entry-point": "0x3b5bb56b", "read-only": false }, "approve": { @@ -239,8 +293,8 @@ "return": "", "description": "Grant permissions to other account to manage a specific Token owned by the user. The user must approve only the accounts he trust.", "entry_point": 1960973952, - "entry-point": "0x74e21680", "read_only": false, + "entry-point": "0x74e21680", "read-only": false }, "set_approval_for_all": { @@ -248,131 +302,183 @@ "return": "", "description": "Grant permissions to other account to manage all Tokens owned by the user. The user must approve only the accounts he trust.", "entry_point": 541336086, - "entry-point": "0x20442216", "read_only": false, + "entry-point": "0x20442216", "read-only": false } }, + "types": "CoQDCidrb2lub3Nib3gtcHJvdG8vbWFuYXNoYXJlci9jb21tb24ucHJvdG8SBmNvbW1vbhoUa29pbm9zL29wdGlvbnMucHJvdG8iG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RhZGF0YV9hcmdzEh8KCHRva2VuX2lkGAEgASgMQgSAtRgCUgd0b2tlbklkEisKEXBlcm1hbmVudF9hZGRyZXNzGAMgASgIUhBwZXJtYW5lbnRBZGRyZXNzElAKJWFkZHJlc3NfbW9kaWZpYWJsZV9vbmx5X2J5X2dvdmVybmFuY2UYBCABKAhSIWFkZHJlc3NNb2RpZmlhYmxlT25seUJ5R292ZXJuYW5jZRIUCgVvdGhlchgKIAEoDFIFb3RoZXIiyQEKEWV4dGVuZGVkX21ldGFkYXRhEh8KCHRva2VuX2lkGAEgASgMQgSAtRgCUgd0b2tlbklkEisKEXBlcm1hbmVudF9hZGRyZXNzGAMgASgIUhBwZXJtYW5lbnRBZGRyZXNzElAKJWFkZHJlc3NfbW9kaWZpYWJsZV9vbmx5X2J5X2dvdmVybmFuY2UYBCABKAhSIWFkZHJlc3NNb2RpZmlhYmxlT25seUJ5R292ZXJuYW5jZRIUCgVvdGhlchgKIAEoDFIFb3RoZXIiqQEKDGFkZHJlc3NfZGF0YRIaCgV2YWx1ZRgBIAEoDEIEgLUYBlIFdmFsdWUSKwoRcGVybWFuZW50X2FkZHJlc3MYAiABKAhSEHBlcm1hbmVudEFkZHJlc3MSUAolYWRkcmVzc19tb2RpZmlhYmxlX29ubHlfYnlfZ292ZXJuYW5jZRgDIAEoCFIhYWRkcmVzc01vZGlmaWFibGVPbmx5QnlHb3Zlcm5hbmNlIo4BChpnZXRfdG9rZW5zX2J5X2FkZHJlc3NfYXJncxIeCgdhZGRyZXNzGAEgASgMQgSAtRgGUgdhZGRyZXNzEhoKBXN0YXJ0GAIgASgMQgSAtRgCUgVzdGFydBIUCgVsaW1pdBgDIAEoBVIFbGltaXQSHgoKZGVzY2VuZGluZxgEIAEoCFIKZGVzY2VuZGluZ2IGcHJvdG8z", "koilib_types": { "nested": { - "common": { + "nicknames": { "nested": { - "str": { + "tabi_item": { "fields": { - "value": { + "pattern": { "type": "string", "id": 1 + }, + "entry_point": { + "type": "uint32", + "id": 2 } } }, - "uint32": { + "tabi": { "fields": { - "value": { - "type": "uint32", + "items": { + "rule": "repeated", + "type": ".nicknames.tabi_item", "id": 1 } } }, - "uint64": { + "get_tabi_result": { "fields": { - "value": { - "type": "uint64", + "items": { + "rule": "repeated", + "type": ".nicknames.tabi_item", + "id": 1 + }, + "address": { + "type": "bytes", + "id": 2, + "options": { + "(koinos.btype)": "ADDRESS" + } + } + } + }, + "set_tabi_args": { + "fields": { + "token_id": { + "type": "bytes", "id": 1, "options": { - "jstype": "JS_STRING" + "(koinos.btype)": "HEX" } + }, + "tabi": { + "type": ".nicknames.tabi", + "id": 2 } } }, - "boole": { + "set_address_args": { "fields": { - "value": { + "token_id": { + "type": "bytes", + "id": 1, + "options": { + "(koinos.btype)": "HEX" + } + }, + "address": { + "type": "bytes", + "id": 2, + "options": { + "(koinos.btype)": "ADDRESS" + } + }, + "gov_proposal_update": { "type": "bool", - "id": 1 + "id": 3 } } }, - "address": { + "set_extended_metadata_args": { "fields": { - "account": { + "token_id": { "type": "bytes", "id": 1, "options": { - "(koinos.btype)": "ADDRESS" + "(koinos.btype)": "HEX" } + }, + "permanent_address": { + "type": "bool", + "id": 3 + }, + "address_modifiable_only_by_governance": { + "type": "bool", + "id": 4 + }, + "other": { + "type": "bytes", + "id": 10 } } }, - "direction": { - "values": { - "ascending": 0, - "descending": 1 + "extended_metadata": { + "fields": { + "token_id": { + "type": "bytes", + "id": 1, + "options": { + "(koinos.btype)": "HEX" + } + }, + "permanent_address": { + "type": "bool", + "id": 3 + }, + "address_modifiable_only_by_governance": { + "type": "bool", + "id": 4 + }, + "other": { + "type": "bytes", + "id": 10 + } } }, - "list_args": { + "address_data": { "fields": { - "start": { + "value": { "type": "bytes", "id": 1, "options": { "(koinos.btype)": "ADDRESS" } }, - "limit": { - "type": "int32", + "permanent_address": { + "type": "bool", "id": 2 }, - "direction": { - "type": "direction", + "address_modifiable_only_by_governance": { + "type": "bool", "id": 3 } } }, - "addresses": { + "get_tokens_by_address_args": { "fields": { - "accounts": { - "rule": "repeated", + "address": { "type": "bytes", "id": 1, "options": { "(koinos.btype)": "ADDRESS" } + }, + "start": { + "type": "bytes", + "id": 2, + "options": { + "(koinos.btype)": "HEX" + } + }, + "limit": { + "type": "int32", + "id": 3 + }, + "descending": { + "type": "bool", + "id": 4 } } } } }, - "koinos": { - "options": { - "go_package": "github.com/koinos/koinos-proto-golang/koinos" - }, - "nested": { - "bytes_type": { - "values": { - "BASE64": 0, - "BASE58": 1, - "HEX": 2, - "BLOCK_ID": 3, - "TRANSACTION_ID": 4, - "CONTRACT_ID": 5, - "ADDRESS": 6 - } - }, - "_btype": { - "oneof": [ - "btype" - ] - }, - "btype": { - "type": "bytes_type", - "id": 50000, - "extend": "google.protobuf.FieldOptions", - "options": { - "proto3_optional": true - } - } - } - }, "nft": { "nested": { "royalty": { @@ -397,7 +503,7 @@ "fields": { "value": { "rule": "repeated", - "type": "royalty", + "type": ".nft.royalty", "id": 1 } } @@ -430,6 +536,10 @@ "uri": { "type": "string", "id": 3 + }, + "description": { + "type": "string", + "id": 4 } } }, @@ -524,6 +634,10 @@ "options": { "(koinos.btype)": "HEX" } + }, + "memo": { + "type": "string", + "id": 4 } } }, @@ -574,12 +688,6 @@ } } }, - "direction": { - "values": { - "ascending": 0, - "descending": 1 - } - }, "get_operators_args": { "fields": { "owner": { @@ -600,8 +708,8 @@ "type": "int32", "id": 3 }, - "direction": { - "type": "direction", + "descending": { + "type": "bool", "id": 4 } } @@ -638,8 +746,8 @@ "type": "int32", "id": 2 }, - "direction": { - "type": "direction", + "descending": { + "type": "bool", "id": 3 } } @@ -664,8 +772,8 @@ "type": "int32", "id": 3 }, - "direction": { - "type": "direction", + "descending": { + "type": "bool", "id": 4 } } @@ -684,29 +792,82 @@ } } }, - "nicknames": { + "common": { "nested": { - "tabi": { + "str": { "fields": { - "patterns": { - "rule": "repeated", + "value": { "type": "string", "id": 1 } } }, - "set_tabi_args": { + "uint32": { "fields": { - "token_id": { + "value": { + "type": "uint32", + "id": 1 + } + } + }, + "uint64": { + "fields": { + "value": { + "type": "uint64", + "id": 1, + "options": { + "jstype": "JS_STRING" + } + } + } + }, + "boole": { + "fields": { + "value": { + "type": "bool", + "id": 1 + } + } + }, + "address": { + "fields": { + "value": { "type": "bytes", "id": 1, "options": { - "(koinos.btype)": "HEX" + "(koinos.btype)": "ADDRESS" + } + } + } + }, + "list_args": { + "fields": { + "start": { + "type": "bytes", + "id": 1, + "options": { + "(koinos.btype)": "ADDRESS" } }, - "tabi": { - "type": "tabi", + "limit": { + "type": "int32", "id": 2 + }, + "descending": { + "type": "bool", + "id": 3 + } + } + }, + "addresses": { + "fields": { + "accounts": { + "rule": "repeated", + "type": "bytes", + "id": 1, + "options": { + "(koinos.btype)": "ADDRESS" + } } } } @@ -716,30 +877,47 @@ }, "events": { "collections.mint_event": { + "type": "nft.mint_args", "argument": "nft.mint_args" }, "collections.burn_event": { + "type": "nft.burn_args", "argument": "nft.burn_args" }, "collections.transfer_event": { - "argument": "nft.transfer_args" - }, - "collections.transferred_to_community": { + "type": "nft.transfer_args", "argument": "nft.transfer_args" }, "nicknames.set_tabi": { + "type": "nicknames.set_tabi_args", "argument": "nicknames.set_tabi_args" }, "collections.set_metadata_event": { + "type": "nft.metadata_args", "argument": "nft.metadata_args" }, + "address_updated": { + "type": "nicknames.set_address_args", + "argument": "nicknames.set_address_args" + }, + "extended_metadata_updated": { + "type": "nicknames.extended_metadata", + "argument": "nicknames.extended_metadata" + }, + "collections.owner_event": { + "type": "common.address", + "argument": "common.address" + }, "collections.royalties_event": { + "type": "nft.royalties", "argument": "nft.royalties" }, "collections.token_approval_event": { + "type": "nft.approve_args", "argument": "nft.approve_args" }, "collections.operator_approval_event": { + "type": "nft.set_approval_for_all_args", "argument": "nft.set_approval_for_all_args" } } diff --git a/services/nicknames.ts b/services/nicknames.ts index 32abc6a..0855e4d 100644 --- a/services/nicknames.ts +++ b/services/nicknames.ts @@ -14,6 +14,15 @@ function getContract(): Contract { }) } +export async function resolveNickname(name: string): Promise { + const contract = getContract() + const { result } = await contract.functions.get_address({ + value: name.replace('@', '') + }) + + return result?.value +} + export async function getNicknameOwner(name: string): Promise { const contract = getContract() const token_id = `0x${utils.toHexString(new TextEncoder().encode(name.replace('@', '')))}` diff --git a/utils/addresses.ts b/utils/addresses.ts index f1e0db5..cf0fb4c 100644 --- a/utils/addresses.ts +++ b/utils/addresses.ts @@ -2,7 +2,7 @@ import { getKAPName } from '@/services/kap' import { Serializer, utils } from 'koilib' import { AppError } from './errors' import { getProvider } from './providers' -import { getNicknameOwner } from '@/services/nicknames' +import { resolveNickname } from '@/services/nicknames' let contractAddresses: Record = {}; @@ -31,10 +31,10 @@ export async function getAddress(str: string) { // nicknames else if (str.startsWith('@')) { - const owner = await getNicknameOwner(str) - if (owner) { - contractAddresses[str] = owner; - return owner + const address = await resolveNickname(str) + if (address) { + contractAddresses[str] = address; + return address } }