Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
147 commits
Select commit Hold shift + click to select a range
dadee6c
Setup env
krebernisak Sep 25, 2025
0b6c1aa
Add TON domain - add configurer
krebernisak Sep 25, 2025
bce0349
Encode SetConfig message
krebernisak Sep 25, 2025
e5cb725
Add ton.ConfigTransformer
krebernisak Sep 25, 2025
d801b7a
Implement transformer.ToConfig
krebernisak Sep 25, 2025
d1b8e19
Add sdk/ton/encoder.go
krebernisak Sep 26, 2025
d045e7b
Add TON Encoder.HashMetadata
krebernisak Sep 26, 2025
31235d4
Add sdk/ton/inspector.go
krebernisak Sep 26, 2025
13b2123
Add sdk.Inspector#GetRootMetadata
krebernisak Sep 26, 2025
b1a90ec
Add sdk/ton/timelock_inspector.go
krebernisak Sep 28, 2025
4c1aad7
Add sdk/ton/transaction.go
krebernisak Sep 28, 2025
78321f0
Add sdk/ton/timelock_executor.go
krebernisak Oct 22, 2025
613e14f
Add sdk/ton/timelock_converter.go
krebernisak Oct 22, 2025
b8ec853
Add sdk/ton/executor.go
krebernisak Oct 22, 2025
d32ef0a
Add signature and proof encoders
krebernisak Oct 22, 2025
46b1b72
Update signatures and proof encoders type
krebernisak Oct 22, 2025
2abd3a2
Add sdk/ton/decoder.go
krebernisak Oct 28, 2025
dd0203e
Bump github.com/smartcontractkit/chainlink-ton
krebernisak Oct 29, 2025
7fd021f
Add cselectors.FamilyTon as option
krebernisak Oct 29, 2025
326ca59
Add changesets and test entrypoints
krebernisak Oct 29, 2025
63a9711
Add TON e2e setup + TimelockInspectionTestSuite stub (evm)
krebernisak Oct 29, 2025
f1899ba
Add Configurer option to not send transactions (NONEVM-2862) - TON
krebernisak Oct 29, 2025
e30648e
Add sdk/ton/decoded_operation_test.go
krebernisak Oct 29, 2025
67690a3
Add sdk/ton/decoder_test.go
krebernisak Oct 29, 2025
9fd3682
Add sdk/ton/encoder_test.go
krebernisak Oct 30, 2025
3b112bc
Add sdk/ton/config_transformer_test.go
krebernisak Oct 31, 2025
66730c3
Add sdk/ton/timelock_converter_test.go
krebernisak Nov 1, 2025
c5964f6
Configure mockery v2
krebernisak Nov 2, 2025
04f7da4
Bump chainlink-ton
krebernisak Nov 2, 2025
f805749
Add wallet.TonAPI mock
krebernisak Nov 2, 2025
0875eac
Add sdk/ton/configurer_test.go
krebernisak Nov 2, 2025
6bf69cd
Add sdk/ton/executor_test.go
krebernisak Nov 3, 2025
09acecd
Add sdk/ton/timelock_executor_test.go
krebernisak Nov 3, 2025
0f8631e
Add timelock inspector getRoleMembers helper func
krebernisak Nov 3, 2025
ee4b46f
Add sdk/ton/timelock_inspector_test.go
krebernisak Nov 3, 2025
c4b0450
Add sdk/ton/timelock_inspector_test.go
krebernisak Nov 4, 2025
f13419c
Reuse common signing test with EVM
krebernisak Nov 7, 2025
c61c279
Apply PR feedback
krebernisak Nov 7, 2025
ec4494f
Add e2e/tests/ton/set_config.go
krebernisak Nov 7, 2025
daf7c2e
Load MCMS (chainlink-ton) contracts
krebernisak Nov 7, 2025
e06ed5f
Implement e2e/tests/ton/set_config.go
krebernisak Nov 9, 2025
9eafc33
Import code from chainlink-ton
krebernisak Nov 9, 2025
15ffd4f
Update upstream deps
krebernisak Nov 24, 2025
3744493
Fix unit tests
krebernisak Nov 24, 2025
0da4b9e
Fix e2e test
krebernisak Nov 24, 2025
4dca120
Remove unused deployerKey from tests
krebernisak Nov 24, 2025
f987b9b
Add SignerKeys slice of keys to types.Config + remap func
krebernisak Nov 25, 2025
e5e84fc
Revert "Add SignerKeys slice of keys to types.Config + remap func"
krebernisak Nov 27, 2025
0ea69e8
Fix after commit revert
krebernisak Nov 27, 2025
103437b
Refactor TON signers as EVM addr
krebernisak Nov 27, 2025
dbf56de
Add e2e/tests/ton/set_root.go (wip)
krebernisak Nov 27, 2025
53e6429
Implement e2e/tests/ton/timelock_inspection.go (wip)
krebernisak Nov 28, 2025
b4b6172
Add tracetracking.WaitForTrace and fix tests
krebernisak Dec 1, 2025
658e984
Add 'Build TON contracts' step to CI e2e tests
krebernisak Dec 1, 2025
3c9d219
Add e2e/tests/ton/inspection.go (wip)
krebernisak Dec 1, 2025
f79fcd3
Fix setConfig payload/test
krebernisak Dec 1, 2025
dd82b5f
PR feedback
krebernisak Dec 2, 2025
60971bd
Remove replace github.com/fbsobreira/gotron-sdk
krebernisak Dec 2, 2025
72fa87d
Extract common deploy functionality
krebernisak Dec 2, 2025
0234945
Update smartcontractkit/.github/actions/ci-lint-go to 3.1.0
krebernisak Dec 2, 2025
1177963
Bump golangci-lint-version: v2.6.2
krebernisak Dec 2, 2025
9b51ba4
Fix lint errors (wip)
krebernisak Dec 2, 2025
af6a74b
Fix lint errors #2 (wip)
krebernisak Dec 2, 2025
da77616
Fix lint errors #3 - renaming (wip)
krebernisak Dec 2, 2025
f1050eb
Fix lint errors #4 (wip)
krebernisak Dec 2, 2025
6635601
Fix lint errors #5 (wip)
krebernisak Dec 2, 2025
08a3368
Fix lint errors #6 (wip)
krebernisak Dec 2, 2025
9db8a3f
Fix lint errors #7 (wip)
krebernisak Dec 2, 2025
648d813
Fix lint errors #8 (wip)
krebernisak Dec 2, 2025
5bd3fd6
Fix lint errors #9 (wip)
krebernisak Dec 2, 2025
67fdc34
Fix lint errors #10 (wip)
krebernisak Dec 2, 2025
7faa57d
Fix lint errors #11 (wip)
krebernisak Dec 2, 2025
9e32578
Fix lint errors #12 (wip)
krebernisak Dec 2, 2025
5d1d2bd
Fix lint errors #13 (wip)
krebernisak Dec 2, 2025
b483dc1
Fix lint errors #14 (wip)
krebernisak Dec 2, 2025
5172cea
Fix lint errors #15 (wip)
krebernisak Dec 2, 2025
dfba8b7
Fix lint errors #16 (wip)
krebernisak Dec 2, 2025
e676dca
Fix lint errors #17 (wip)
krebernisak Dec 2, 2025
fa99902
Fix lint errors #18 (wip)
krebernisak Dec 2, 2025
7a46f9e
Fix s.Run func
krebernisak Dec 2, 2025
d559024
Fix lint errors #19 (wip)
krebernisak Dec 2, 2025
5b6b3d9
Fix lint errors #20 (wip)
krebernisak Dec 2, 2025
8168758
Fix lint errors #21 (wip)
krebernisak Dec 2, 2025
10be31a
Fix lint errors #22 (wip)
krebernisak Dec 2, 2025
ba4aec6
Fix lint errors #23 (wip)
krebernisak Dec 2, 2025
231f2fc
Fix lint errors #24 (wip)
krebernisak Dec 2, 2025
d70a6f6
Fix lint errors #25 (wip)
krebernisak Dec 2, 2025
cc812ed
Fix lint errors #26 (wip)
krebernisak Dec 2, 2025
6f60982
Fix lint errors #27 (wip)
krebernisak Dec 2, 2025
805f5f8
Fix lint errors #28 (wip)
krebernisak Dec 2, 2025
8dce922
Fix lint errors #29 (wip)
krebernisak Dec 2, 2025
d2ce4dd
Fix lint errors #30 (wip)
krebernisak Dec 2, 2025
85580b3
Fix lint errors #31 (wip)
krebernisak Dec 2, 2025
0e396db
Fix lint errors #32 (wip)
krebernisak Dec 3, 2025
cae301f
Fix lint errors #33 (wip)
krebernisak Dec 3, 2025
96c1200
Fix lint errors #34 (wip)
krebernisak Dec 3, 2025
a2ff9da
Add .golangci.yml settings.gomoddirectives.replace-allow-list gogo/pr…
krebernisak Dec 3, 2025
e92726b
Use .golangci.yml in CI
krebernisak Dec 3, 2025
71681d6
golangci-lint run --fix --config .golangci.yml
krebernisak Dec 3, 2025
2f3aff8
Fix lint errors #35 (wip)
krebernisak Dec 3, 2025
7d882da
TODO(ton) annotation
krebernisak Dec 3, 2025
b6f401b
Merge branch 'main' into feat/ton-support
krebernisak Dec 5, 2025
cf4948e
fix import
huangzhen1997 Dec 8, 2025
0579b4c
Fix merge + reuse code
krebernisak Dec 9, 2025
f079f52
Fix TimelockCall min value
krebernisak Dec 9, 2025
69c162a
Fix import
krebernisak Dec 9, 2025
d7136b9
Remove ConfigTransformer as inspector arg
krebernisak Dec 9, 2025
e96490b
Apply feedback from Pablo
krebernisak Dec 9, 2025
5431a6a
Fix EVM test - error check
krebernisak Dec 9, 2025
a879bac
Add TestIsOperationDone
krebernisak Dec 10, 2025
9517329
Fix TestIsOperationDone
krebernisak Dec 10, 2025
c52a686
Update to chore/mcms-polish-4 upstream branch - fix EIP191 signing an…
krebernisak Dec 11, 2025
123dc48
Add shim for GLOBAL_ID issue
krebernisak Dec 11, 2025
30ad9a9
Fix unit test
krebernisak Dec 11, 2025
a0e7628
Rollback style/lint changes
krebernisak Dec 11, 2025
6687331
Fix flakes - addr cmp, uint160
krebernisak Dec 12, 2025
7b6d4e2
Update to latest smartcontractkit/chainlink-ton
krebernisak Dec 12, 2025
f8f530e
Bump to latest smartcontractkit/chainlink-ton
krebernisak Dec 12, 2025
11fe398
Revert style/lint changes
krebernisak Dec 12, 2025
a82b15f
Import tvm.NewRandomTestWallet fn
krebernisak Dec 12, 2025
b0a4e27
Bump to latest smartcontractkit/chainlink-ton
krebernisak Dec 12, 2025
217ff57
Bump to latest smartcontractkit/chainlink-ton (main)
krebernisak Dec 12, 2025
24a92b3
Bump to latest smartcontractkit/chainlink-ton (mcms-bindings)
krebernisak Dec 12, 2025
bcdc4eb
Bump to latest smartcontractkit/chainlink-ton (mcms-bindings)
krebernisak Dec 12, 2025
05a6893
Cleanup TLBMap injection
krebernisak Dec 15, 2025
924e72b
Add configurer WithDoNotSendInstructionsOnChain test
krebernisak Dec 15, 2025
34ad98f
Decoder - Handle message with no body - empty cell
krebernisak Dec 15, 2025
2ebd436
Cleanup sdk/ton/timelock_converter_test.go
krebernisak Dec 15, 2025
86ec5e3
Add e2e/tests/ton/executable.go (wip)
krebernisak Dec 16, 2025
3c32706
Fix test
krebernisak Dec 16, 2025
cf9de69
Fix lint
krebernisak Dec 16, 2025
3a8c127
Fix lint
krebernisak Dec 16, 2025
c2ca592
Bump to latest, test TimelockInspector
krebernisak Dec 16, 2025
fd43ba7
Fix mcmston.NewTimelockConverter(mcmston.DefaultSendAmount)
krebernisak Dec 16, 2025
447799e
Fix lint
krebernisak Dec 16, 2025
1907ec4
Docs
krebernisak Dec 16, 2025
2da298b
Fix timelock test gas issue
krebernisak Dec 16, 2025
af713b0
Add GenSimpleTestConfig fn
krebernisak Dec 16, 2025
d1013f7
Move underlying getters to chainlink-ton
krebernisak Dec 17, 2025
2032363
Add sdk/ton/transaction_test.go
krebernisak Dec 17, 2025
8771cdb
Extract ParseAddrGetBlock(ctx, client, address) util
krebernisak Dec 17, 2025
8065364
Bump to latest
krebernisak Dec 17, 2025
87dfcb6
Bump to latest, remove duplicated code
krebernisak Dec 17, 2025
70cbb32
Extract SendTx util fn
krebernisak Dec 17, 2025
5c04a63
Add coverage, fix deploy bug
krebernisak Dec 17, 2025
60de5d1
Bump to latest
krebernisak Dec 18, 2025
cfba89d
Update to latest chainlink-ton (generic-ops)
krebernisak Dec 29, 2025
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
5 changes: 5 additions & 0 deletions .changeset/long-snakes-ring.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@smartcontractkit/mcms": minor
---

Add TON implementation and unit/e2e tests
21 changes: 20 additions & 1 deletion .github/workflows/pull-request-main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,11 @@ jobs:
contents: read
actions: read
steps:
- name: Install Nix
uses: cachix/install-nix-action@02a151ada4993995686f9ed4f1be7cfbb229e56f # v31
with:
nix_path: nixpkgs=channel:nixos-unstable

- name: Install Rust
uses: moonrepo/setup-rust@ede6de059f8046a5e236c94046823e2af11ca670 # v1.2.2

Expand Down Expand Up @@ -114,6 +119,14 @@ jobs:
run: |
./e2e/tests/solana/compile-mcm-contracts.sh

- name: Build TON contracts
id: ton-contracts-build
shell: bash
run: |
PATH_CONTRACTS_TON_PKG="$(nix build .#chainlink-ton-contracts --print-out-paths)/"
PATH_CONTRACTS_TON="$PATH_CONTRACTS_TON_PKG/lib/node_modules/@chainlink/contracts-ton/build/"
echo "path=$PATH_CONTRACTS_TON" >> "$GITHUB_OUTPUT"

- name: Run e2e tests
uses: smartcontractkit/.github/actions/ci-test-go@ci-test-go/1.0.0
with:
Expand All @@ -138,11 +151,17 @@ jobs:
CTF_CONFIGS=../config.sui.toml go test -p=1 -tags=e2e -v ./e2e/tests/... -run=TestSuiSuite || sui_failure=true
echo "::endgroup::"

echo "::group::TON"
export PATH_CONTRACTS_TON="${{ steps.ton-contracts-build.outputs.path }}"
CTF_CONFIGS=../config.ton.toml go test -p=1 -tags=e2e -v ./e2e/tests/... -run=TestTONSuite || ton_failure=true
echo "::endgroup::"

[[ -n "${evm_failure}" ]] && echo "🚨 EVM e2e tests failed."
[[ -n "${solana_failure}" ]] && echo "🚨 Solana e2e tests failed."
[[ -n "${aptos_failure}" ]] && echo "🚨 Aptos e2e tests failed."
[[ -n "${sui_failure}" ]] && echo "🚨 Sui e2e tests failed."
[[ -n "${evm_failure}" || -n "${solana_failure}" || -n "${aptos_failure}" || -n "${sui_failure}" ]] && {
[[ -n "${ton_failure}" ]] && echo "🚨 TON e2e tests failed."
[[ -n "${evm_failure}" || -n "${solana_failure}" || -n "${aptos_failure}" || -n "${sui_failure}" || -n "${ton_failure}" ]] && {
exit 1
} || {
echo "Exiting"
Expand Down
18 changes: 18 additions & 0 deletions .mockery.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,24 @@ mockname: "{{.InterfaceName}}"
inpackage: false
outpkg: mocks
packages:
github.com/xssnick/tonutils-go/ton/wallet:
config:
all: false
outpkg: "mock_ton"
interfaces:
TonAPI:
config:
dir: "./sdk/ton/mocks"
filename: "wallet.go"
github.com/xssnick/tonutils-go/ton:
config:
all: false
outpkg: "mock_ton"
interfaces:
APIClientWrapped:
config:
dir: "./sdk/ton/mocks"
filename: "api.go"
github.com/smartcontractkit/mcms/sdk:
github.com/smartcontractkit/mcms/sdk/evm:
github.com/smartcontractkit/mcms/sdk/evm/bindings:
Expand Down
18 changes: 18 additions & 0 deletions e2e/config.ton.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
[settings]
private_keys = [
"0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80",
"0x59c6995e998f97a5a0044966f0945389dc9e86dae88c7a8412f4603b6b78690d",
"0x5de4111afa1a4b94908f83103eb1f1706367c2e68ca870fc3fb9a804cdab365a"
]

[ton_config]
chain_id = "-217"
type = "ton"
image = "ghcr.io/neodix42/mylocalton-docker:v3.97"

[ton_config.out]
family = "ton"

[ton_config.custom_env]
NEXT_BLOCK_GENERATION_DELAY = "0.5"
VERSION_CAPABILITIES = "12"
3 changes: 1 addition & 2 deletions e2e/tests/aptos/set_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ package aptos

import (
"slices"
"strings"

"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/crypto"
Expand All @@ -30,7 +29,7 @@ func (a *TestSuite) TestSetConfig() {
signers[i] = crypto.PubkeyToAddress(key.PublicKey)
}
slices.SortFunc(signers[:], func(a, b common.Address) int {
return strings.Compare(strings.ToLower(a.Hex()), strings.ToLower(b.Hex()))
return a.Cmp(b)
})

bypasserConfig := &types.Config{
Expand Down
10 changes: 10 additions & 0 deletions e2e/tests/runner_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (
evme2e "github.com/smartcontractkit/mcms/e2e/tests/evm"
solanae2e "github.com/smartcontractkit/mcms/e2e/tests/solana"
suie2e "github.com/smartcontractkit/mcms/e2e/tests/sui"
tone2e "github.com/smartcontractkit/mcms/e2e/tests/ton"
)

func TestEVMSuite(t *testing.T) {
Expand Down Expand Up @@ -39,3 +40,12 @@ func TestSuiSuite(t *testing.T) {
suite.Run(t, new(suie2e.TimelockCancelProposalTestSuite))
suite.Run(t, new(suie2e.MCMSUserUpgradeTestSuite))
}

func TestTONSuite(t *testing.T) {
suite.Run(t, new(tone2e.SigningTestSuite))
suite.Run(t, new(tone2e.SetConfigTestSuite))
suite.Run(t, new(tone2e.SetRootTestSuite))
suite.Run(t, new(tone2e.InspectionTestSuite))
suite.Run(t, new(tone2e.ExecutionTestSuite))
suite.Run(t, new(tone2e.TimelockInspectionTestSuite))
}
32 changes: 32 additions & 0 deletions e2e/tests/setup.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ import (
"github.com/gagliardetto/solana-go/rpc/ws"
"github.com/joho/godotenv"
"github.com/stretchr/testify/require"
"github.com/xssnick/tonutils-go/ton"

tonchain "github.com/smartcontractkit/chainlink-ton/pkg/ton/chain"

"github.com/smartcontractkit/chainlink-testing-framework/framework"
"github.com/smartcontractkit/chainlink-testing-framework/framework/components/blockchain"
Expand All @@ -39,6 +42,7 @@ type Config struct {
SolanaChain *blockchain.Input `toml:"solana_config"`
AptosChain *blockchain.Input `toml:"aptos_config"`
SuiChain *blockchain.Input `toml:"sui_config"`
TonChain *blockchain.Input `toml:"ton_config"`

Settings struct {
PrivateKeys []string `toml:"private_keys"`
Expand All @@ -57,6 +61,8 @@ type TestSetup struct {
AptosBlockchain *blockchain.Output
SuiClient sui.ISuiAPI
SuiBlockchain *blockchain.Output
TonClient *ton.APIClient
TonBlockchain *blockchain.Output
Config
}

Expand Down Expand Up @@ -203,6 +209,30 @@ func InitializeSharedTestSetup(t *testing.T) *TestSetup {
t.Logf("Initialized Sui RPC client @ %s", nodeURL)
}

var (
tonClient *ton.APIClient
tonBlockchainOutput *blockchain.Output
)
if in.TonChain != nil {
// Use blockchain network setup (fallback)
ports := freeport.GetN(t, 2)
port := ports[0]
faucetPort := ports[1]
in.TonChain.Port = strconv.Itoa(port)
in.TonChain.FaucetPort = strconv.Itoa(faucetPort)

tonBlockchainOutput, err = blockchain.NewBlockchainNetwork(in.TonChain)
require.NoError(t, err, "Failed to initialize TON blockchain")

nodeURL := tonBlockchainOutput.Nodes[0].ExternalHTTPUrl
pool, err := tonchain.CreateLiteserverConnectionPool(ctx, nodeURL)
require.NoError(t, err, "Failed to initialize TON client - failed to create liteserver connection pool")
tonClient = ton.NewAPIClient(pool, ton.ProofCheckPolicyFast)

// Test liveness, will also fetch ChainID
t.Logf("Initialized TON RPC client @ %s", nodeURL)
}

sharedSetup = &TestSetup{
ClientA: ethClientA,
ClientB: ethClientB,
Expand All @@ -213,6 +243,8 @@ func InitializeSharedTestSetup(t *testing.T) *TestSetup {
AptosBlockchain: aptosBlockchainOutput,
SuiClient: suiClient,
SuiBlockchain: suiBlockchainOutput,
TonClient: tonClient,
TonBlockchain: tonBlockchainOutput,
Config: *in,
}
})
Expand Down
3 changes: 1 addition & 2 deletions e2e/tests/sui/set_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ package sui

import (
"slices"
"strings"

"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/crypto"
Expand All @@ -26,7 +25,7 @@ func (s *TestSuite) TestSetConfig() {
signers[i] = crypto.PubkeyToAddress(key.PublicKey)
}
slices.SortFunc(signers[:], func(a, b common.Address) int {
return strings.Compare(strings.ToLower(a.Hex()), strings.ToLower(b.Hex()))
return a.Cmp(b)
})

bypasserConfig := &types.Config{
Expand Down
122 changes: 122 additions & 0 deletions e2e/tests/ton/common.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,122 @@
//go:build e2e

package tone2e

import (
"context"
"fmt"
"os"
"path/filepath"

"github.com/ethereum/go-ethereum/common"

"github.com/xssnick/tonutils-go/address"
"github.com/xssnick/tonutils-go/tlb"
"github.com/xssnick/tonutils-go/ton"
"github.com/xssnick/tonutils-go/ton/wallet"
"github.com/xssnick/tonutils-go/tvm/cell"

"github.com/smartcontractkit/chainlink-ton/pkg/bindings/mcms/mcms"
"github.com/smartcontractkit/chainlink-ton/pkg/bindings/mcms/timelock"
"github.com/smartcontractkit/chainlink-ton/pkg/ton/tracetracking"
"github.com/smartcontractkit/chainlink-ton/pkg/ton/wrappers"

"github.com/smartcontractkit/mcms/internal/testutils"
"github.com/smartcontractkit/mcms/types"
)

const (
EnvPathContracts = "PATH_CONTRACTS_TON"

PathContractsMCMS = "mcms.MCMS.compiled.json"
PathContractsTimelock = "mcms.RBACTimelock.compiled.json"
)

func must[E any](out E, err error) E {
if err != nil {
panic(err)
}

return out
}

type DeployOpts struct {
// Connection
Client *ton.APIClient
Wallet *wallet.Wallet

// Deployment info
ContractPath string

Amount tlb.Coins
Data any
Body any
}

func DeployContract(ctx context.Context, opts DeployOpts) (*address.Address, error) {
contractCode, err := wrappers.ParseCompiledContract(opts.ContractPath)
if err != nil {
return nil, fmt.Errorf("failed to parse compiled contract: %w", err)
}

contractData, ok := opts.Data.(*cell.Cell) // Cell or we try to decode
if !ok {
contractData, err = tlb.ToCell(opts.Data)
if err != nil {
return nil, fmt.Errorf("failed to create contract data cell: %w", err)
}
}

bodyCell, ok := opts.Body.(*cell.Cell) // Cell or we try to decode
if !ok {
bodyCell, err = tlb.ToCell(opts.Body)
if err != nil {
return nil, fmt.Errorf("failed to create contract body cell: %w", err)
}
}

_client := tracetracking.NewSignedAPIClient(opts.Client, *opts.Wallet)
contract, _, err := wrappers.Deploy(ctx, &_client, contractCode, contractData, opts.Amount, bodyCell)
if err != nil {
return nil, fmt.Errorf("failed to deploy contract: %w", err)
}

return contract.Address, nil
}

func DeployMCMSContract(ctx context.Context, client *ton.APIClient, w *wallet.Wallet, amount tlb.Coins, data mcms.Data) (*address.Address, error) {
return DeployContract(ctx, DeployOpts{
Client: client,
Wallet: w,
ContractPath: filepath.Join(os.Getenv(EnvPathContracts), PathContractsMCMS),
Amount: amount,
Data: data,
Body: cell.BeginCell().EndCell(), // empty cell, top up
})
}

func DeployTimelockContract(ctx context.Context, client *ton.APIClient, w *wallet.Wallet, amount tlb.Coins, data timelock.Data, body timelock.Init) (*address.Address, error) {
return DeployContract(ctx, DeployOpts{
Client: client,
Wallet: w,
ContractPath: filepath.Join(os.Getenv(EnvPathContracts), PathContractsTimelock),
Amount: amount,
Data: data,
Body: body,
})
}

// GenSimpleTestMCMSConfig generates a simple test configuration that's used in e2e tests.
func GenSimpleTestMCMSConfig(signers []testutils.ECDSASigner) *types.Config {
return &types.Config{
Quorum: 1,
Signers: []common.Address{signers[0].Address()},
GroupSigners: []types.Config{
{
Quorum: 1,
Signers: []common.Address{signers[1].Address()},
GroupSigners: []types.Config{},
},
},
}
}
Loading
Loading