diff --git a/ton/wallet/highloadv2r2.go b/ton/wallet/highloadv2r2.go index 4078d6c..599b959 100644 --- a/ton/wallet/highloadv2r2.go +++ b/ton/wallet/highloadv2r2.go @@ -22,7 +22,7 @@ type SpecHighloadV2R2 struct { SpecQuery } -func (s *SpecHighloadV2R2) BuildMessage(_ context.Context, messages []*Message) (*cell.Cell, error) { +func (s *SpecHighloadV2R2) BuildMessage(ctx context.Context, messages []*Message) (*cell.Cell, error) { if len(messages) > 254 { return nil, errors.New("for this type of wallet max 254 messages can be sent in the same time") } @@ -47,7 +47,7 @@ func (s *SpecHighloadV2R2) BuildMessage(_ context.Context, messages []*Message) var ttl, queryID uint32 if s.customQueryIDFetcher != nil { - ttl, queryID = s.customQueryIDFetcher() + ttl, queryID = s.customQueryIDFetcher(ctx) } else { queryID = randUint32() ttl = uint32(timeNow().Add(time.Duration(s.messagesTTL) * time.Second).UTC().Unix()) diff --git a/ton/wallet/regular.go b/ton/wallet/regular.go index cfd8468..54d9d89 100644 --- a/ton/wallet/regular.go +++ b/ton/wallet/regular.go @@ -54,9 +54,15 @@ type SpecQuery struct { // Do not set ttl to high if you are sending many messages, // unexpired executed messages will be cached in contract, // and it may become too expensive to make transactions. - customQueryIDFetcher func() (ttl uint32, randPart uint32) + customQueryIDFetcher func(context.Context) (ttl uint32, randPart uint32) } func (s *SpecQuery) SetCustomQueryIDFetcher(fetcher func() (ttl uint32, randPart uint32)) { + s.SetCustomQueryIDFetcherWithContext(func(ctx context.Context) (ttl uint32, randPart uint32) { + return fetcher() + }) +} + +func (s *SpecQuery) SetCustomQueryIDFetcherWithContext(fetcher func(ctx context.Context) (ttl uint32, randPart uint32)) { s.customQueryIDFetcher = fetcher }