From 4576516c08ec2703a91dd78319e9b60f3b68cfba Mon Sep 17 00:00:00 2001 From: Alexey Kostenko Date: Thu, 15 Aug 2024 19:33:48 +0300 Subject: [PATCH 1/3] specifying root DNS in the SetDefaultExecutor --- account.go | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/account.go b/account.go index 00113a22..86a0b7e5 100644 --- a/account.go +++ b/account.go @@ -48,12 +48,32 @@ func DefaultAddressParser() *addressParser { return defaultParser } +type ParserOptions struct { + RootDNS AccountID + Executor abi.Executor +} + +type ParserOption func(options *ParserOptions) + +func WithRootDNS(root AccountID) ParserOption { + return func(options *ParserOptions) { + options.RootDNS = root + } +} + // SetDefaultExecutor sets the default executor for the default address parser. // The executor is used to resolve DNS records. -func SetDefaultExecutor(executor abi.Executor) { +func SetDefaultExecutor(executor abi.Executor, opts ...ParserOption) { + options := &ParserOptions{ + RootDNS: MustParseAccountID(DefaultRoot), + Executor: executor, + } + for _, f := range opts { + f(options) + } mu.Lock() defer mu.Unlock() - resolver := dns.NewDNS(MustParseAccountID(DefaultRoot), executor) + resolver := dns.NewDNS(options.RootDNS, options.Executor) defaultParser = NewAccountAddressParser(resolver) } From 350d25f689eb88f80160af6589424fb1f409722f Mon Sep 17 00:00:00 2001 From: Alexey Kostenko Date: Thu, 15 Aug 2024 19:45:19 +0300 Subject: [PATCH 2/3] fix test --- address_test.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/address_test.go b/address_test.go index b1bf0574..9b851858 100644 --- a/address_test.go +++ b/address_test.go @@ -52,8 +52,8 @@ func TestParseAddress(t *testing.T) { { name: "Parse dns to raw address", typeParse: parseDnsToRawAddress, - request: "subbotin.ton", - response: "0:2cf3b5b8c891e517c9addbda1c0386a09ccacbb0e3faf630b51cfc8152325acb", + request: "wallet-ton.ton", + response: "0:b9fa6045aee35c428b4f7fa9f0e6dfd2e51253a6e7c661b76d6803796ebf80c5", }, { name: "url-unsafe", From 7a4a126539ac9dc46d4595c87f910dc692436d3a Mon Sep 17 00:00:00 2001 From: Alexey Kostenko Date: Thu, 15 Aug 2024 19:54:52 +0300 Subject: [PATCH 3/3] fix test --- abi/generated_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/abi/generated_test.go b/abi/generated_test.go index a46eac3e..a5f6fb2c 100644 --- a/abi/generated_test.go +++ b/abi/generated_test.go @@ -587,7 +587,7 @@ func TestWhalesNominators(t *testing.T) { if len(members.List.Keys()) == 0 { t.Fatal(len(members.List.Keys())) } - memberAddress := ton.NewAccountID(0, members.List.Keys()[4]) + memberAddress := ton.NewAccountID(0, members.List.Keys()[0]) _, v, err = GetMember(context.Background(), client, address, memberAddress.ToMsgAddress()) if err != nil { t.Fatal(err)