Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rename w5 plugins to extensions #265

Merged
merged 1 commit into from
Jun 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions wallet/wallet_v5.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ type DataV5 struct {
Seqno tlb.Uint33
WalletID WalletV5ID
PublicKey tlb.Bits256
PluginDict tlb.HashmapE[tlb.Bits256, tlb.Uint8]
Extensions tlb.HashmapE[tlb.Bits256, tlb.Uint8]
}

type walletV5 struct {
Expand Down Expand Up @@ -159,19 +159,19 @@ func unpackAddr(wc int8, addr [32]byte) ton.AccountID {
}
}

// GetW5PluginList returns a list of wallet v5 extensions added to a specific wallet.
func GetW5PluginList(state tlb.ShardAccount) (map[ton.AccountID]struct{}, error) {
// GetW5ExtensionsList returns a list of wallet v5 extensions added to a specific wallet.
func GetW5ExtensionsList(state tlb.ShardAccount) (map[ton.AccountID]struct{}, error) {
if state.Account.Status() == tlb.AccountActive {
var data DataV5
cell := boc.Cell(state.Account.Account.Storage.State.AccountActive.StateInit.Data.Value.Value)
if err := tlb.Unmarshal(&cell, &data); err != nil {
return nil, err
}
if len(data.PluginDict.Keys()) == 0 {
if len(data.Extensions.Keys()) == 0 {
return nil, nil
}
extensions := make(map[ton.AccountID]struct{}, len(data.PluginDict.Keys()))
for _, item := range data.PluginDict.Items() {
extensions := make(map[ton.AccountID]struct{}, len(data.Extensions.Keys()))
for _, item := range data.Extensions.Items() {
extensions[unpackAddr(int8(item.Value), item.Key)] = struct{}{}
}
return extensions, nil
Expand Down
8 changes: 4 additions & 4 deletions wallet/wallet_v5_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (
"github.com/tonkeeper/tongo/ton"
)

func TestGetW5PluginList(t *testing.T) {
func TestGetW5ExtensionsList(t *testing.T) {
tests := []struct {
name string
accountID string
Expand All @@ -36,12 +36,12 @@ func TestGetW5PluginList(t *testing.T) {
if err != nil {
t.Fatalf("GetAccountState() error = %v", err)
}
extensions, err := GetW5PluginList(state)
extensions, err := GetW5ExtensionsList(state)
if err != nil {
t.Fatalf("GetW5PluginList() error = %v", err)
t.Fatalf("GetW5ExtensionsList() error = %v", err)
}
if !reflect.DeepEqual(extensions, tt.wantExtensions) {
t.Errorf("GetW5PluginList() = %v, want %v", extensions, tt.wantExtensions)
t.Errorf("GetW5ExtensionsList() = %v, want %v", extensions, tt.wantExtensions)
}
})
}
Expand Down
Loading