Skip to content

Commit

Permalink
Rename w5 plugins to extensions
Browse files Browse the repository at this point in the history
  • Loading branch information
aleksej-paschenko committed Jun 4, 2024
1 parent e8aa956 commit 1d64f6a
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
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

0 comments on commit 1d64f6a

Please sign in to comment.