Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
3 changes: 3 additions & 0 deletions config.e2e-local.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ canton:
token:
cip56_package_id: "c8c6fe7c34d96b88d6471769aae85063c8045783b2a226fd24f8c573603d17c2"
splice_transfer_package_id: "55ba4deb0ad4662c4168b39859738a0e91388d252286480c7331b3f71a517281"
splice_holding_package_id: "placeholder-updated-by-bootstrap"

bridge:
package_id: "6fac182df4943e7e2f70360b413b6e3ab10e65289ba0d971978b6d861a860d72"
Expand All @@ -67,10 +68,12 @@ token:
name: "PROMPT"
symbol: "PROMPT"
decimals: 18
instrument_id: "PROMPT"
"0xDE30000000000000000000000000000000000001":
name: "Demo Token"
symbol: "DEMO"
decimals: 18
instrument_id: "DEMO"
native_balance_wei: "1000000000000000000000"

# Ethereum JSON-RPC facade (MetaMask compatibility)
Expand Down
4 changes: 4 additions & 0 deletions pkg/cantonsdk/token/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ type Config struct {

CIP56PackageID string `yaml:"cip56_package_id" validate:"required"`
SpliceTransferPackageID string `yaml:"splice_transfer_package_id" validate:"required"`
SpliceHoldingPackageID string `yaml:"splice_holding_package_id" validate:"required"`
Comment thread
salindne marked this conversation as resolved.
}

func (c *Config) validate() error {
Expand All @@ -31,5 +32,8 @@ func (c *Config) validate() error {
if c.SpliceTransferPackageID == "" {
return errors.New("splice_transfer_package_id is required")
}
if c.SpliceHoldingPackageID == "" {
return errors.New("splice_holding_package_id is required")
}
return nil
}
3 changes: 3 additions & 0 deletions pkg/config/defaults/config.api-server.docker.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ canton:
token:
cip56_package_id: "c8c6fe7c34d96b88d6471769aae85063c8045783b2a226fd24f8c573603d17c2"
splice_transfer_package_id: "55ba4deb0ad4662c4168b39859738a0e91388d252286480c7331b3f71a517281"
splice_holding_package_id: "718a0f77e505a8de22f188bd4c87fe74101274e9d4cb1bfac7d09aec7158d35b"

bridge:
package_id: "6fac182df4943e7e2f70360b413b6e3ab10e65289ba0d971978b6d861a860d72"
Expand All @@ -58,10 +59,12 @@ token:
name: "PROMPT"
symbol: "PROMPT"
decimals: 18
instrument_id: "PROMPT"
"0xDE30000000000000000000000000000000000001":
name: "Demo Token"
symbol: "DEMO"
decimals: 18
instrument_id: "DEMO"
native_balance_wei: "1000000000000000000000"

# Ethereum JSON-RPC facade (MetaMask compatibility)
Expand Down
3 changes: 3 additions & 0 deletions pkg/config/defaults/config.api-server.local-devnet.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ canton:
token:
cip56_package_id: "c8c6fe7c34d96b88d6471769aae85063c8045783b2a226fd24f8c573603d17c2"
splice_transfer_package_id: "55ba4deb0ad4662c4168b39859738a0e91388d252286480c7331b3f71a517281"
splice_holding_package_id: "718a0f77e505a8de22f188bd4c87fe74101274e9d4cb1bfac7d09aec7158d35b"

bridge:
package_id: "6fac182df4943e7e2f70360b413b6e3ab10e65289ba0d971978b6d861a860d72"
Expand All @@ -52,10 +53,12 @@ token:
name: "PROMPT"
symbol: "PROMPT"
decimals: 18
instrument_id: "PROMPT"
"0xDE30000000000000000000000000000000000001":
name: "Demo Token"
symbol: "DEMO"
decimals: 18
instrument_id: "DEMO"
native_balance_wei: "1000000000000000000000"

# Ethereum JSON-RPC facade (MetaMask compatibility)
Expand Down
2 changes: 2 additions & 0 deletions pkg/config/defaults/config.api-server.mainnet.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ canton:
token:
cip56_package_id: "${CANTON_CIP56_PACKAGE_ID}"
splice_transfer_package_id: "${CANTON_SPLICE_TRANSFER_PACKAGE_ID}"
splice_holding_package_id: "718a0f77e505a8de22f188bd4c87fe74101274e9d4cb1bfac7d09aec7158d35b"
Comment thread
salindne marked this conversation as resolved.
Outdated

bridge:
package_id: "${CANTON_BRIDGE_PACKAGE_ID}"
Expand All @@ -50,6 +51,7 @@ token:
name: "Demo Token"
symbol: "DEMO"
decimals: 18
instrument_id: "DEMO"
native_balance_wei: "1000000000000000000000"

eth_rpc:
Expand Down
1 change: 1 addition & 0 deletions pkg/config/defaults/config.relayer.docker.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ canton:
token:
cip56_package_id: "c8c6fe7c34d96b88d6471769aae85063c8045783b2a226fd24f8c573603d17c2"
splice_transfer_package_id: "55ba4deb0ad4662c4168b39859738a0e91388d252286480c7331b3f71a517281"
splice_holding_package_id: "718a0f77e505a8de22f188bd4c87fe74101274e9d4cb1bfac7d09aec7158d35b"

bridge:
package_id: "6fac182df4943e7e2f70360b413b6e3ab10e65289ba0d971978b6d861a860d72"
Expand Down
1 change: 1 addition & 0 deletions pkg/config/defaults/config.relayer.local-devnet.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ canton:
token:
cip56_package_id: "c8c6fe7c34d96b88d6471769aae85063c8045783b2a226fd24f8c573603d17c2"
splice_transfer_package_id: "55ba4deb0ad4662c4168b39859738a0e91388d252286480c7331b3f71a517281"
splice_holding_package_id: "718a0f77e505a8de22f188bd4c87fe74101274e9d4cb1bfac7d09aec7158d35b"

bridge:
package_id: "6fac182df4943e7e2f70360b413b6e3ab10e65289ba0d971978b6d861a860d72"
Expand Down
1 change: 1 addition & 0 deletions pkg/config/defaults/config.relayer.mainnet.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ canton:
token:
cip56_package_id: "${CANTON_CIP56_PACKAGE_ID}"
splice_transfer_package_id: "${CANTON_SPLICE_TRANSFER_PACKAGE_ID}"
splice_holding_package_id: "718a0f77e505a8de22f188bd4c87fe74101274e9d4cb1bfac7d09aec7158d35b"
Comment thread
salindne marked this conversation as resolved.
Outdated

bridge:
package_id: "${CANTON_BRIDGE_PACKAGE_ID}"
Expand Down
2 changes: 2 additions & 0 deletions pkg/config/tests/env-substitution.api.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,15 @@ canton:
token:
cip56_package_id: "cip56-package"
splice_transfer_package_id: "splice-package"
splice_holding_package_id: "test-splice-holding-pkg-id"

token:
supported_tokens:
"0x0000000000000000000000000000000000000001":
name: "PROMPT"
symbol: "PROMPT"
decimals: 18
instrument_id: "PROMPT"

eth_rpc:
chain_id: 31337
Expand Down
2 changes: 2 additions & 0 deletions pkg/config/tests/invalid-database-url.api.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,15 @@ canton:
token:
cip56_package_id: "cip56-package"
splice_transfer_package_id: "splice-package"
splice_holding_package_id: "test-splice-holding-pkg-id"

token:
supported_tokens:
"0x0000000000000000000000000000000000000001":
name: "PROMPT"
symbol: "PROMPT"
decimals: 18
instrument_id: "PROMPT"

eth_rpc:
chain_id: 31337
Expand Down
2 changes: 2 additions & 0 deletions pkg/config/tests/minimal.api.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,15 @@ canton:
token:
cip56_package_id: "cip56-package"
splice_transfer_package_id: "splice-package"
splice_holding_package_id: "test-splice-holding-pkg-id"

token:
supported_tokens:
"0x0000000000000000000000000000000000000001":
name: "PROMPT"
symbol: "PROMPT"
decimals: 18
instrument_id: "PROMPT"

eth_rpc:
chain_id: 31337
Expand Down
1 change: 1 addition & 0 deletions pkg/config/tests/minimal.relayer.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ canton:
token:
cip56_package_id: "cip56-package"
splice_transfer_package_id: "splice-package"
splice_holding_package_id: "test-splice-holding-pkg-id"

bridge:
max_transfer_amount: "1000"
Expand Down
2 changes: 2 additions & 0 deletions pkg/config/tests/missing-env.api.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,15 @@ canton:
token:
cip56_package_id: "cip56-package"
splice_transfer_package_id: "splice-package"
splice_holding_package_id: "test-splice-holding-pkg-id"

token:
supported_tokens:
"0x0000000000000000000000000000000000000001":
name: "PROMPT"
symbol: "PROMPT"
decimals: 18
instrument_id: "PROMPT"

eth_rpc:
chain_id: 31337
Expand Down
1 change: 1 addition & 0 deletions pkg/config/tests/missing-required.relayer.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ canton:
token:
cip56_package_id: "cip56-package"
splice_transfer_package_id: "splice-package"
splice_holding_package_id: "test-splice-holding-pkg-id"

bridge:
max_transfer_amount: "1000"
Expand Down
1 change: 1 addition & 0 deletions pkg/config/tests/monitoring-enabled-no-server.relayer.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ canton:
token:
cip56_package_id: "cip56-package"
splice_transfer_package_id: "splice-package"
splice_holding_package_id: "test-splice-holding-pkg-id"

bridge:
max_transfer_amount: "1000"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ canton:
token:
cip56_package_id: "cip56-package"
splice_transfer_package_id: "splice-package"
splice_holding_package_id: "test-splice-holding-pkg-id"

bridge:
max_transfer_amount: "1000"
Expand Down
1 change: 1 addition & 0 deletions pkg/config/tests/unknown-field.relayer.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ canton:
token:
cip56_package_id: "cip56-package"
splice_transfer_package_id: "splice-package"
splice_holding_package_id: "test-splice-holding-pkg-id"

bridge:
max_transfer_amount: "1000"
Expand Down
10 changes: 6 additions & 4 deletions pkg/token/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,13 @@ import (
"github.com/ethereum/go-ethereum/common"
)

// ERC20Token contains ERC-20 token metadata
// ERC20Token contains ERC-20 token metadata and Canton instrument mapping.
type ERC20Token struct {
Name string `yaml:"name" validate:"required"`
Symbol string `yaml:"symbol" validate:"required"`
Decimals int `yaml:"decimals" validate:"gte=0,lte=18"`
Name string `yaml:"name" validate:"required"`
Symbol string `yaml:"symbol" validate:"required"`
Decimals int `yaml:"decimals" validate:"gte=0,lte=18"`
InstrumentID string `yaml:"instrument_id" validate:"required"`
InstrumentAdmin string `yaml:"instrument_admin"` // defaults to IssuerParty if empty
Comment thread
salindne marked this conversation as resolved.
Outdated
Comment thread
salindne marked this conversation as resolved.
Outdated
}

// Config holds token metadata indexed by contract address.
Expand Down
8 changes: 4 additions & 4 deletions pkg/token/erc20_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ var (

func newCfg() *token.Config {
cfg := token.NewConfig("5000000000000000000") // 5 ETH in wei
cfg.AddToken(promptAddr, token.ERC20Token{Name: "Prompt Token", Symbol: "PROMPT", Decimals: 18})
cfg.AddToken(demoAddr, token.ERC20Token{Name: "Demo Token", Symbol: "DEMO", Decimals: 18})
cfg.AddToken(promptAddr, token.ERC20Token{Name: "Prompt Token", Symbol: "PROMPT", Decimals: 18, InstrumentID: "PROMPT"})
cfg.AddToken(demoAddr, token.ERC20Token{Name: "Demo Token", Symbol: "DEMO", Decimals: 18, InstrumentID: "DEMO"})
return cfg
}

Expand Down Expand Up @@ -98,7 +98,7 @@ func TestERC20_Decimals(t *testing.T) {
t.Run("decimals value 255 (MaxUint8) is preserved", func(t *testing.T) {
cfg := newCfg()
addr255 := common.HexToAddress("0x3000000000000000000000000000000000000003")
cfg.AddToken(addr255, token.ERC20Token{Name: "T255", Symbol: "T255", Decimals: 255})
cfg.AddToken(addr255, token.ERC20Token{Name: "T255", Symbol: "T255", Decimals: 255, InstrumentID: "T255"})
svc := token.NewTokenService(cfg, nil, nil, nil)
erc20 := token.NewERC20(addr255, svc)

Expand All @@ -108,7 +108,7 @@ func TestERC20_Decimals(t *testing.T) {
t.Run("decimals value 256 (> MaxUint8) returns zero", func(t *testing.T) {
cfg := newCfg()
addr256 := common.HexToAddress("0x4000000000000000000000000000000000000004")
cfg.AddToken(addr256, token.ERC20Token{Name: "T256", Symbol: "T256", Decimals: 256})
cfg.AddToken(addr256, token.ERC20Token{Name: "T256", Symbol: "T256", Decimals: 256, InstrumentID: "T256"})
svc := token.NewTokenService(cfg, nil, nil, nil)
erc20 := token.NewERC20(addr256, svc)

Expand Down
4 changes: 2 additions & 2 deletions tests/e2e/devstack/system/system.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,11 @@ type Tokens struct {
func NewTokens(manifest *stack.ServiceManifest) *Tokens {
return &Tokens{
DEMO: stack.Token{
ERC20Token: token.ERC20Token{Symbol: "DEMO", Decimals: 18},
ERC20Token: token.ERC20Token{Symbol: "DEMO", Decimals: 18, InstrumentID: "DEMO"},
Address: common.HexToAddress(manifest.DemoTokenAddr),
},
PROMPT: stack.Token{
ERC20Token: token.ERC20Token{Symbol: "PROMPT", Decimals: 18},
ERC20Token: token.ERC20Token{Symbol: "PROMPT", Decimals: 18, InstrumentID: "PROMPT"},
Address: common.HexToAddress(manifest.PromptTokenAddr),
},
}
Expand Down
Loading