forked from tonkeeper/opentonapi
-
Notifications
You must be signed in to change notification settings - Fork 0
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
21 changed files
with
857 additions
and
98 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
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
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
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
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
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
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
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
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
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
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 bath | ||
|
||
import ( | ||
"github.com/tonkeeper/tongo/abi" | ||
"github.com/tonkeeper/tongo/tlb" | ||
"github.com/tonkeeper/tongo/ton" | ||
) | ||
|
||
type BubbleDnsItemRenew struct { | ||
DnsRenewAction | ||
Success bool | ||
} | ||
|
||
type DnsRenewAction struct { | ||
Item ton.AccountID | ||
Renewer ton.AccountID | ||
} | ||
|
||
func (b BubbleDnsItemRenew) ToAction() *Action { | ||
return &Action{Success: b.Success, Type: DnsRenew, DnsRenew: &b.DnsRenewAction} | ||
} | ||
|
||
func (a DnsRenewAction) SubjectAccounts() []ton.AccountID { | ||
return []ton.AccountID{a.Renewer, a.Item} | ||
} | ||
|
||
var DNSRenewStraw = Straw[BubbleDnsItemRenew]{ | ||
CheckFuncs: []bubbleCheck{IsTx, HasOperation(abi.DeleteDnsRecordMsgOp), HasInterface(abi.NftItem), func(bubble *Bubble) bool { | ||
return bubble.Info.(BubbleTx).decodedBody.Value.(abi.DeleteDnsRecordMsgBody).Key.Equal(tlb.Bits256{}) | ||
}}, | ||
Builder: func(newAction *BubbleDnsItemRenew, bubble *Bubble) error { | ||
tx := bubble.Info.(BubbleTx) | ||
newAction.Renewer = tx.inputFrom.Address | ||
newAction.Item = tx.account.Address | ||
return nil | ||
}, | ||
SingleChild: &Straw[BubbleDnsItemRenew]{ | ||
Optional: true, | ||
CheckFuncs: []bubbleCheck{IsTx, HasOperation(abi.BounceMsgOp)}, | ||
}, | ||
} |
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,109 @@ | ||
package bath | ||
|
||
import ( | ||
"fmt" | ||
"github.com/tonkeeper/opentonapi/internal/g" | ||
"github.com/tonkeeper/tongo/abi" | ||
) | ||
|
||
var NftTransferNotifyStraw = Straw[BubbleNftTransfer]{ | ||
CheckFuncs: []bubbleCheck{IsTx, HasOperation(abi.NftOwnershipAssignedMsgOp)}, | ||
Builder: func(newAction *BubbleNftTransfer, bubble *Bubble) error { | ||
receiverTx := bubble.Info.(BubbleTx) | ||
transfer := receiverTx.decodedBody.Value.(abi.NftOwnershipAssignedMsgBody) | ||
newAction.success = true | ||
if receiverTx.inputFrom == nil { | ||
return fmt.Errorf("nft transfer notify without sender") | ||
} | ||
newAction.account = *receiverTx.inputFrom | ||
if newAction.sender == nil { | ||
newAction.sender = parseAccount(transfer.PrevOwner) | ||
} | ||
newAction.recipient = &receiverTx.account | ||
newAction.payload = transfer.ForwardPayload.Value | ||
return nil | ||
}, | ||
} | ||
|
||
var NftTransferStraw = Straw[BubbleNftTransfer]{ | ||
CheckFuncs: []bubbleCheck{IsTx, HasOperation(abi.NftTransferMsgOp)}, | ||
Builder: func(newAction *BubbleNftTransfer, bubble *Bubble) error { | ||
tx := bubble.Info.(BubbleTx) | ||
transfer := tx.decodedBody.Value.(abi.NftTransferMsgBody) | ||
newAction.account = tx.account | ||
newAction.success = tx.success | ||
newAction.sender = tx.inputFrom | ||
newAction.payload = transfer.ForwardPayload.Value | ||
if newAction.recipient == nil { | ||
newAction.recipient = parseAccount(transfer.NewOwner) | ||
} | ||
return nil | ||
}, | ||
Children: []Straw[BubbleNftTransfer]{ | ||
Optional(NftTransferNotifyStraw), | ||
{ | ||
CheckFuncs: []bubbleCheck{IsTx, HasOperation(abi.ExcessMsgOp)}, | ||
Optional: true, | ||
}, | ||
}, | ||
} | ||
|
||
type BubbleNftTransfer struct { | ||
success bool | ||
account Account | ||
sender *Account | ||
recipient *Account | ||
payload abi.NFTPayload | ||
} | ||
|
||
func (b BubbleNftTransfer) ToAction() (action *Action) { | ||
a := Action{ | ||
NftItemTransfer: &NftTransferAction{ | ||
Recipient: b.recipient.Addr(), | ||
Sender: b.sender.Addr(), | ||
Nft: b.account.Address, | ||
}, | ||
Success: b.success, | ||
Type: NftItemTransfer, | ||
} | ||
switch b.payload.SumType { | ||
case abi.TextCommentNFTOp: | ||
a.NftItemTransfer.Comment = g.Pointer(string(b.payload.Value.(abi.TextCommentNFTPayload).Text)) | ||
case abi.EncryptedTextCommentNFTOp: | ||
a.NftItemTransfer.EncryptedComment = &EncryptedComment{ | ||
CipherText: b.payload.Value.(abi.EncryptedTextCommentNFTPayload).CipherText, | ||
EncryptionType: "simple", | ||
} | ||
case abi.EmptyNFTOp: | ||
default: | ||
if b.payload.SumType != abi.UnknownNFTOp { | ||
a.NftItemTransfer.Comment = g.Pointer("Call: " + b.payload.SumType) | ||
} else if b.recipient != nil && b.recipient.Is(abi.Wallet) { | ||
// we don't want to show the scary "Call: Ugly HEX" to the wallet contract | ||
} else if b.payload.OpCode != nil { | ||
a.NftItemTransfer.Comment = g.Pointer(fmt.Sprintf("Call: 0x%08x", *b.payload.OpCode)) | ||
} | ||
} | ||
return &a | ||
} | ||
|
||
//type BubbleNftMint struct { | ||
// Minter *ton.AccountID | ||
// Owner *ton.AccountID | ||
// Item ton.AccountID | ||
//} | ||
// | ||
//func (b BubbleNftMint) ToAction() *Action { | ||
// //TODO implement me | ||
// panic("implement me") | ||
//} | ||
// | ||
//var NFTMintStraw = Straw[BubbleNftMint]{ | ||
// | ||
// Children: []Straw[BubbleNftMint]{ | ||
// { | ||
// | ||
// }, | ||
// }, | ||
// CheckFuncs: []bubbleCheck{Is(BubbleContractDeploy{})}, | ||
//} |
Oops, something went wrong.