-
Notifications
You must be signed in to change notification settings - Fork 55
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
164 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
package precompiled | ||
|
||
import ( | ||
"math/big" | ||
|
||
"github.com/tonkeeper/tongo/boc" | ||
"github.com/tonkeeper/tongo/tlb" | ||
) | ||
|
||
// todo: need to cover test corner cases about int size near int64 max value | ||
// DO NOT USE UNTIL FIX TODO!!! | ||
var jettonV1getWalletData = func(data *boc.Cell, args tlb.VmStack) (tlb.VmStack, error) { | ||
var body struct { | ||
Amount tlb.VarUInteger16 | ||
Owner tlb.MsgAddress | ||
Master tlb.MsgAddress | ||
Code boc.Cell `tlb:"^"` | ||
} | ||
err := tlb.Unmarshal(data, &body) | ||
if err != nil { | ||
return nil, err | ||
} | ||
var result = make([]tlb.VmStackValue, 4) | ||
var b = big.Int(body.Amount) | ||
if b.IsInt64() { | ||
result[0] = tlb.VmStackValue{ | ||
SumType: "VmStkTinyInt", | ||
VmStkTinyInt: b.Int64(), | ||
} | ||
} else { | ||
result[0] = tlb.VmStackValue{ | ||
SumType: "VmStkInt", | ||
VmStkInt: tlb.Int257(b), | ||
} | ||
} | ||
ownerCell := boc.NewCell() | ||
masterCell := boc.NewCell() | ||
err = tlb.Marshal(ownerCell, body.Owner) | ||
if err != nil { | ||
return nil, err | ||
} | ||
err = tlb.Marshal(masterCell, body.Master) | ||
if err != nil { | ||
return nil, err | ||
} | ||
result[1], err = tlb.CellToVmCellSlice(ownerCell) | ||
if err != nil { | ||
return nil, err | ||
} | ||
result[2], err = tlb.CellToVmCellSlice(masterCell) | ||
if err != nil { | ||
return nil, err | ||
} | ||
result[3] = tlb.VmStackValue{ | ||
SumType: "VmStkCell", | ||
VmStkCell: tlb.Ref[boc.Cell]{Value: body.Code}, | ||
} | ||
return result, nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
package precompiled | ||
|
||
import ( | ||
"github.com/tonkeeper/tongo/boc" | ||
"github.com/tonkeeper/tongo/tlb" | ||
) | ||
|
||
var getPowParamsGram = func(data *boc.Cell, args tlb.VmStack) (tlb.VmStack, error) { | ||
var body struct { | ||
Skip1 uint64 | ||
Skip2 tlb.Bits256 | ||
Value1 tlb.Uint128 | ||
Value2 tlb.Uint256 | ||
Field1 struct { | ||
Value3 tlb.Grams | ||
Value4 uint32 | ||
} `tlb:"^"` | ||
} | ||
err := tlb.Unmarshal(data, &body) | ||
if err != nil { | ||
return nil, err | ||
} | ||
return tlb.VmStack{ | ||
{ | ||
SumType: "VmStkInt", | ||
VmStkInt: tlb.Int257(body.Value1), | ||
}, | ||
{ | ||
SumType: "VmStkInt", | ||
VmStkInt: tlb.Int257(body.Value2), | ||
}, | ||
{ | ||
SumType: "VmStkTinyInt", | ||
VmStkTinyInt: int64(body.Field1.Value3), | ||
}, | ||
{ | ||
SumType: "VmStkTinyInt", | ||
VmStkTinyInt: int64(body.Field1.Value4), | ||
}, | ||
}, nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
package precompiled | ||
|
||
import ( | ||
"math/big" | ||
|
||
"github.com/tonkeeper/tongo/boc" | ||
"github.com/tonkeeper/tongo/tlb" | ||
) | ||
|
||
var walletv4r2seqno = func(data *boc.Cell, args tlb.VmStack) (tlb.VmStack, error) { | ||
var dataV4 struct { | ||
Seqno uint32 | ||
SubWalletId uint32 | ||
PublicKey tlb.Bits256 | ||
} | ||
err := tlb.Unmarshal(data, &dataV4) | ||
if err != nil { | ||
return nil, err | ||
} | ||
return tlb.VmStack{ | ||
{ | ||
SumType: "VmStkTinyInt", | ||
VmStkTinyInt: int64(dataV4.Seqno), | ||
}, | ||
}, nil | ||
} | ||
|
||
var walletv4r2SubwalletID = func(data *boc.Cell, args tlb.VmStack) (tlb.VmStack, error) { | ||
var dataV4 struct { | ||
Seqno uint32 | ||
SubWalletId uint32 | ||
PublicKey tlb.Bits256 | ||
} | ||
err := tlb.Unmarshal(data, &dataV4) | ||
if err != nil { | ||
return nil, err | ||
} | ||
return tlb.VmStack{ | ||
{ | ||
SumType: "VmStkTinyInt", | ||
VmStkTinyInt: int64(dataV4.SubWalletId), | ||
}, | ||
}, nil | ||
} | ||
|
||
var walletv4r2publicKey = func(data *boc.Cell, args tlb.VmStack) (tlb.VmStack, error) { | ||
var dataV4 struct { | ||
Seqno uint32 | ||
SubWalletId uint32 | ||
PublicKey tlb.Bits256 | ||
} | ||
err := tlb.Unmarshal(data, &dataV4) | ||
if err != nil { | ||
return nil, err | ||
} | ||
var b big.Int | ||
b.SetBytes(dataV4.PublicKey[:]) | ||
return tlb.VmStack{ | ||
{ | ||
SumType: "VmStkInt", | ||
VmStkInt: tlb.Int257(b), | ||
}, | ||
}, nil | ||
} |