From deb6cef5feb5e78b9a9d143f86f8c528b2202514 Mon Sep 17 00:00:00 2001 From: Andrew Richardson Date: Thu, 17 Mar 2022 15:19:16 -0400 Subject: [PATCH 1/5] Store TXType in token events Because some token transactions may generate events of multiple types (such as a transfer triggering approval changes as a side effect), the transaction type must be stored instead of being inferred from the event. Signed-off-by: Andrew Richardson --- internal/events/token_pool_created.go | 19 ++-- internal/events/token_pool_created_test.go | 116 +++++++++++++-------- internal/tokens/fftokens/fftokens.go | 52 ++++++--- internal/tokens/fftokens/fftokens_test.go | 35 +++++-- pkg/tokens/plugin.go | 5 +- 5 files changed, 144 insertions(+), 83 deletions(-) diff --git a/internal/events/token_pool_created.go b/internal/events/token_pool_created.go index 9fd89f770..b1eb76d54 100644 --- a/internal/events/token_pool_created.go +++ b/internal/events/token_pool_created.go @@ -34,6 +34,9 @@ func addPoolDetailsFromPlugin(ffPool *fftypes.TokenPool, pluginPool *tokens.Toke ffPool.ProtocolID = pluginPool.ProtocolID ffPool.Connector = pluginPool.Connector ffPool.Standard = pluginPool.Standard + if pluginPool.TX.ID != nil { + ffPool.TX = pluginPool.TX + } if pluginPool.Symbol != "" { if ffPool.Symbol == "" { ffPool.Symbol = pluginPool.Symbol @@ -42,12 +45,6 @@ func addPoolDetailsFromPlugin(ffPool *fftypes.TokenPool, pluginPool *tokens.Toke } } ffPool.Info = pluginPool.Info - if pluginPool.TransactionID != nil { - ffPool.TX = fftypes.TransactionRef{ - Type: fftypes.TransactionTypeTokenPool, - ID: pluginPool.TransactionID, - } - } return nil } @@ -95,7 +92,7 @@ func (em *eventManager) shouldConfirm(ctx context.Context, pool *tokens.TokenPoo return existingPool, err } if err = addPoolDetailsFromPlugin(existingPool, pool); err != nil { - log.L(ctx).Errorf("Error processing pool for transaction '%s' (%s) - ignoring", pool.TransactionID, err) + log.L(ctx).Errorf("Error processing pool for transaction '%s' (%s) - ignoring", pool.TX.ID, err) return nil, nil } @@ -112,7 +109,7 @@ func (em *eventManager) shouldConfirm(ctx context.Context, pool *tokens.TokenPoo } func (em *eventManager) shouldAnnounce(ctx context.Context, pool *tokens.TokenPool) (announcePool *fftypes.TokenPool, err error) { - op, err := em.findTXOperation(ctx, pool.TransactionID, fftypes.OpTypeTokenCreatePool) + op, err := em.findTXOperation(ctx, pool.TX.ID, fftypes.OpTypeTokenCreatePool) if err != nil { return nil, err } else if op == nil { @@ -121,12 +118,12 @@ func (em *eventManager) shouldAnnounce(ctx context.Context, pool *tokens.TokenPo announcePool, err = txcommon.RetrieveTokenPoolCreateInputs(ctx, op) if err != nil || announcePool.ID == nil || announcePool.Namespace == "" || announcePool.Name == "" { - log.L(ctx).Errorf("Error loading pool info for transaction '%s' (%s) - ignoring: %v", pool.TransactionID, err, op.Input) + log.L(ctx).Errorf("Error loading pool info for transaction '%s' (%s) - ignoring: %v", pool.TX.ID, err, op.Input) return nil, nil } if err = addPoolDetailsFromPlugin(announcePool, pool); err != nil { - log.L(ctx).Errorf("Error processing pool for transaction '%s' (%s) - ignoring", pool.TransactionID, err) + log.L(ctx).Errorf("Error processing pool for transaction '%s' (%s) - ignoring", pool.TX.ID, err) return nil, nil } return announcePool, nil @@ -157,7 +154,7 @@ func (em *eventManager) TokenPoolCreated(ti tokens.Plugin, pool *tokens.TokenPoo batchID = msg.BatchID // trigger rewind after completion of database transaction } return em.confirmPool(ctx, existingPool, &pool.Event, pool.Event.BlockchainTXID) - } else if pool.TransactionID == nil { + } else if pool.TX.ID == nil { // TransactionID is required if the pool doesn't exist yet // (but it may be omitted when activating a pool that was received via definition broadcast) log.L(em.ctx).Errorf("Invalid token pool transaction - ID is nil") diff --git a/internal/events/token_pool_created_test.go b/internal/events/token_pool_created_test.go index 58753ec13..8c020f25a 100644 --- a/internal/events/token_pool_created_test.go +++ b/internal/events/token_pool_created_test.go @@ -44,10 +44,13 @@ func TestTokenPoolCreatedIgnore(t *testing.T) { operations := []*fftypes.Operation{} info := fftypes.JSONObject{"some": "info"} pool := &tokens.TokenPool{ - Type: fftypes.TokenTypeFungible, - ProtocolID: "123", - TransactionID: txID, - Connector: "erc1155", + Type: fftypes.TokenTypeFungible, + ProtocolID: "123", + TX: fftypes.TransactionRef{ + ID: txID, + Type: fftypes.TransactionTypeTokenPool, + }, + Connector: "erc1155", Event: blockchain.Event{ BlockchainTXID: "0xffffeeee", ProtocolID: "tx1", @@ -72,10 +75,9 @@ func TestTokenPoolCreatedIgnoreNoTX(t *testing.T) { info := fftypes.JSONObject{"some": "info"} pool := &tokens.TokenPool{ - Type: fftypes.TokenTypeFungible, - ProtocolID: "123", - TransactionID: nil, - Connector: "erc1155", + Type: fftypes.TokenTypeFungible, + ProtocolID: "123", + Connector: "erc1155", Event: blockchain.Event{ BlockchainTXID: "0xffffeeee", ProtocolID: "tx1", @@ -102,13 +104,16 @@ func TestTokenPoolCreatedConfirm(t *testing.T) { info1 := fftypes.JSONObject{"pool": "info"} info2 := fftypes.JSONObject{"block": "info"} chainPool := &tokens.TokenPool{ - Type: fftypes.TokenTypeFungible, - ProtocolID: "123", - Connector: "erc1155", - TransactionID: txID, - Standard: "ERC1155", - Symbol: "FFT", - Info: info1, + Type: fftypes.TokenTypeFungible, + ProtocolID: "123", + Connector: "erc1155", + TX: fftypes.TransactionRef{ + ID: txID, + Type: fftypes.TransactionTypeTokenPool, + }, + Standard: "ERC1155", + Symbol: "FFT", + Info: info1, Event: blockchain.Event{ BlockchainTXID: "0xffffeeee", Name: "TokenPool", @@ -170,10 +175,13 @@ func TestTokenPoolCreatedAlreadyConfirmed(t *testing.T) { txID := fftypes.NewUUID() info := fftypes.JSONObject{"some": "info"} chainPool := &tokens.TokenPool{ - Type: fftypes.TokenTypeFungible, - ProtocolID: "123", - Connector: "erc1155", - TransactionID: txID, + Type: fftypes.TokenTypeFungible, + ProtocolID: "123", + Connector: "erc1155", + TX: fftypes.TransactionRef{ + ID: txID, + Type: fftypes.TransactionTypeTokenPool, + }, Event: blockchain.Event{ BlockchainTXID: "0xffffeeee", ProtocolID: "tx1", @@ -208,11 +216,14 @@ func TestTokenPoolCreatedConfirmFailBadSymbol(t *testing.T) { txID := fftypes.NewUUID() info := fftypes.JSONObject{"some": "info"} chainPool := &tokens.TokenPool{ - Type: fftypes.TokenTypeFungible, - ProtocolID: "123", - Connector: "erc1155", - TransactionID: txID, - Symbol: "ETH", + Type: fftypes.TokenTypeFungible, + ProtocolID: "123", + Connector: "erc1155", + TX: fftypes.TransactionRef{ + ID: txID, + Type: fftypes.TransactionTypeTokenPool, + }, + Symbol: "ETH", Event: blockchain.Event{ BlockchainTXID: "0xffffeeee", ProtocolID: "tx1", @@ -253,10 +264,13 @@ func TestTokenPoolCreatedMigrate(t *testing.T) { txID := fftypes.NewUUID() info := fftypes.JSONObject{"some": "info"} chainPool := &tokens.TokenPool{ - Type: fftypes.TokenTypeFungible, - ProtocolID: "123", - Connector: "magic-tokens", - TransactionID: txID, + Type: fftypes.TokenTypeFungible, + ProtocolID: "123", + Connector: "magic-tokens", + TX: fftypes.TransactionRef{ + ID: txID, + Type: fftypes.TransactionTypeTokenPool, + }, Event: blockchain.Event{ BlockchainTXID: "0xffffeeee", ProtocolID: "tx1", @@ -497,10 +511,13 @@ func TestTokenPoolCreatedAnnounce(t *testing.T) { } info := fftypes.JSONObject{"some": "info"} pool := &tokens.TokenPool{ - Type: fftypes.TokenTypeFungible, - ProtocolID: "123", - TransactionID: txID, - Connector: "erc1155", + Type: fftypes.TokenTypeFungible, + ProtocolID: "123", + TX: fftypes.TransactionRef{ + ID: txID, + Type: fftypes.TransactionTypeTokenPool, + }, + Connector: "erc1155", Event: blockchain.Event{ BlockchainTXID: "0xffffeeee", ProtocolID: "tx1", @@ -539,10 +556,13 @@ func TestTokenPoolCreatedAnnounceBadOpInputID(t *testing.T) { } info := fftypes.JSONObject{"some": "info"} pool := &tokens.TokenPool{ - Type: fftypes.TokenTypeFungible, - ProtocolID: "123", - TransactionID: txID, - Connector: "erc1155", + Type: fftypes.TokenTypeFungible, + ProtocolID: "123", + TX: fftypes.TransactionRef{ + ID: txID, + Type: fftypes.TransactionTypeTokenPool, + }, + Connector: "erc1155", Event: blockchain.Event{ BlockchainTXID: "0xffffeeee", ProtocolID: "tx1", @@ -577,10 +597,13 @@ func TestTokenPoolCreatedAnnounceBadOpInputNS(t *testing.T) { } info := fftypes.JSONObject{"some": "info"} pool := &tokens.TokenPool{ - Type: fftypes.TokenTypeFungible, - ProtocolID: "123", - TransactionID: txID, - Connector: "erc1155", + Type: fftypes.TokenTypeFungible, + ProtocolID: "123", + TX: fftypes.TransactionRef{ + ID: txID, + Type: fftypes.TransactionTypeTokenPool, + }, + Connector: "erc1155", Event: blockchain.Event{ BlockchainTXID: "0xffffeeee", ProtocolID: "tx1", @@ -618,11 +641,14 @@ func TestTokenPoolCreatedAnnounceBadSymbol(t *testing.T) { } info := fftypes.JSONObject{"some": "info"} pool := &tokens.TokenPool{ - Type: fftypes.TokenTypeFungible, - ProtocolID: "123", - TransactionID: txID, - Connector: "erc1155", - Symbol: "ETH", + Type: fftypes.TokenTypeFungible, + ProtocolID: "123", + TX: fftypes.TransactionRef{ + ID: txID, + Type: fftypes.TransactionTypeTokenPool, + }, + Connector: "erc1155", + Symbol: "ETH", Event: blockchain.Event{ BlockchainTXID: "0xffffeeee", ProtocolID: "tx1", diff --git a/internal/tokens/fftokens/fftokens.go b/internal/tokens/fftokens/fftokens.go index 13caba678..c6adc4125 100644 --- a/internal/tokens/fftokens/fftokens.go +++ b/internal/tokens/fftokens/fftokens.go @@ -59,9 +59,10 @@ const ( ) type tokenData struct { - TX *fftypes.UUID `json:"tx,omitempty"` - Message *fftypes.UUID `json:"message,omitempty"` - MessageHash *fftypes.Bytes32 `json:"messageHash,omitempty"` + TX *fftypes.UUID `json:"tx,omitempty"` + TXType fftypes.TransactionType `json:"txtype,omitempty"` + Message *fftypes.UUID `json:"message,omitempty"` + MessageHash *fftypes.Bytes32 `json:"messageHash,omitempty"` } type createPool struct { @@ -217,14 +218,22 @@ func (ft *FFTokens) handleTokenPoolCreate(ctx context.Context, data fftypes.JSON poolData = tokenData{} } + txType := poolData.TXType + if txType == "" { + txType = fftypes.TransactionTypeTokenPool + } + pool := &tokens.TokenPool{ - Type: fftypes.FFEnum(tokenType), - ProtocolID: protocolID, - TransactionID: poolData.TX, - Connector: ft.configuredName, - Standard: standard, - Symbol: symbol, - Info: info, + Type: fftypes.FFEnum(tokenType), + ProtocolID: protocolID, + TX: fftypes.TransactionRef{ + ID: poolData.TX, + Type: txType, + }, + Connector: ft.configuredName, + Standard: standard, + Symbol: symbol, + Info: info, Event: blockchain.Event{ BlockchainTXID: txHash, Source: ft.Name() + ":" + ft.configuredName, @@ -295,6 +304,11 @@ func (ft *FFTokens) handleTokenTransfer(ctx context.Context, t fftypes.TokenTran return nil // move on } + txType := transferData.TXType + if txType == "" { + txType = fftypes.TransactionTypeTokenTransfer + } + transfer := &tokens.TokenTransfer{ PoolProtocolID: poolProtocolID, TokenTransfer: fftypes.TokenTransfer{ @@ -311,7 +325,7 @@ func (ft *FFTokens) handleTokenTransfer(ctx context.Context, t fftypes.TokenTran MessageHash: transferData.MessageHash, TX: fftypes.TransactionRef{ ID: transferData.TX, - Type: fftypes.TransactionTypeTokenTransfer, + Type: txType, }, }, Event: blockchain.Event{ @@ -363,6 +377,11 @@ func (ft *FFTokens) handleTokenApproval(ctx context.Context, data fftypes.JSONOb transferData = tokenData{} } + txType := transferData.TXType + if txType == "" { + txType = fftypes.TransactionTypeTokenApproval + } + approval := &tokens.TokenApproval{ PoolProtocolID: poolProtocolID, TokenApproval: fftypes.TokenApproval{ @@ -373,7 +392,7 @@ func (ft *FFTokens) handleTokenApproval(ctx context.Context, data fftypes.JSONOb ProtocolID: eventProtocolID, TX: fftypes.TransactionRef{ ID: transferData.TX, - Type: fftypes.TransactionTypeTokenApproval, + Type: txType, }, }, Event: blockchain.Event{ @@ -450,7 +469,8 @@ func (ft *FFTokens) eventLoop() { func (ft *FFTokens) CreateTokenPool(ctx context.Context, opID *fftypes.UUID, pool *fftypes.TokenPool) (complete bool, err error) { data, _ := json.Marshal(tokenData{ - TX: pool.TX.ID, + TX: pool.TX.ID, + TXType: pool.TX.Type, }) res, err := ft.client.R().SetContext(ctx). SetBody(&createPool{ @@ -502,6 +522,7 @@ func (ft *FFTokens) ActivateTokenPool(ctx context.Context, opID *fftypes.UUID, p func (ft *FFTokens) MintTokens(ctx context.Context, opID *fftypes.UUID, poolProtocolID string, mint *fftypes.TokenTransfer) error { data, _ := json.Marshal(tokenData{ TX: mint.TX.ID, + TXType: mint.TX.Type, Message: mint.Message, MessageHash: mint.MessageHash, }) @@ -525,6 +546,7 @@ func (ft *FFTokens) MintTokens(ctx context.Context, opID *fftypes.UUID, poolProt func (ft *FFTokens) BurnTokens(ctx context.Context, opID *fftypes.UUID, poolProtocolID string, burn *fftypes.TokenTransfer) error { data, _ := json.Marshal(tokenData{ TX: burn.TX.ID, + TXType: burn.TX.Type, Message: burn.Message, MessageHash: burn.MessageHash, }) @@ -548,6 +570,7 @@ func (ft *FFTokens) BurnTokens(ctx context.Context, opID *fftypes.UUID, poolProt func (ft *FFTokens) TransferTokens(ctx context.Context, opID *fftypes.UUID, poolProtocolID string, transfer *fftypes.TokenTransfer) error { data, _ := json.Marshal(tokenData{ TX: transfer.TX.ID, + TXType: transfer.TX.Type, Message: transfer.Message, MessageHash: transfer.MessageHash, }) @@ -571,7 +594,8 @@ func (ft *FFTokens) TransferTokens(ctx context.Context, opID *fftypes.UUID, pool func (ft *FFTokens) TokensApproval(ctx context.Context, opID *fftypes.UUID, poolProtocolID string, approval *fftypes.TokenApproval) error { data, _ := json.Marshal(tokenData{ - TX: approval.TX.ID, + TX: approval.TX.ID, + TXType: approval.TX.Type, }) res, err := ft.client.R().SetContext(ctx). SetBody(&tokenApproval{ diff --git a/internal/tokens/fftokens/fftokens_test.go b/internal/tokens/fftokens/fftokens_test.go index 366cab032..fc9dd00f3 100644 --- a/internal/tokens/fftokens/fftokens_test.go +++ b/internal/tokens/fftokens/fftokens_test.go @@ -128,7 +128,10 @@ func TestCreateTokenPool(t *testing.T) { "config": map[string]interface{}{ "foo": "bar", }, - "data": `{"tx":"` + pool.TX.ID.String() + `"}`, + "data": fftypes.JSONObject{ + "tx": pool.TX.ID.String(), + "txtype": fftypes.TransactionTypeTokenPool.String(), + }.String(), "name": "new-pool", "symbol": "symbol", }, body) @@ -213,7 +216,7 @@ func TestCreateTokenPoolSynchronous(t *testing.T) { mcb := h.callbacks.(*tokenmocks.Callbacks) mcb.On("TokenPoolCreated", h, mock.MatchedBy(func(p *tokens.TokenPool) bool { - return p.ProtocolID == "F1" && p.Type == fftypes.TokenTypeFungible && *p.TransactionID == *pool.TX.ID && p.Event.ProtocolID == "000000000010/000020/000030/000040" + return p.ProtocolID == "F1" && p.Type == fftypes.TokenTypeFungible && *p.TX.ID == *pool.TX.ID && p.Event.ProtocolID == "000000000010/000020/000030/000040" })).Return(nil) complete, err := h.CreateTokenPool(context.Background(), opID, pool) @@ -360,7 +363,7 @@ func TestActivateTokenPoolSynchronous(t *testing.T) { mcb := h.callbacks.(*tokenmocks.Callbacks) mcb.On("TokenPoolCreated", h, mock.MatchedBy(func(p *tokens.TokenPool) bool { - return p.ProtocolID == "F1" && p.Type == fftypes.TokenTypeFungible && p.TransactionID == nil && p.Event.ProtocolID == "" + return p.ProtocolID == "F1" && p.Type == fftypes.TokenTypeFungible && p.TX.ID == nil && p.Event.ProtocolID == "" })).Return(nil) complete, err := h.ActivateTokenPool(context.Background(), opID, pool, txInfo) @@ -403,7 +406,7 @@ func TestActivateTokenPoolSynchronousBadResponse(t *testing.T) { mcb := h.callbacks.(*tokenmocks.Callbacks) mcb.On("TokenPoolCreated", h, mock.MatchedBy(func(p *tokens.TokenPool) bool { - return p.ProtocolID == "F1" && p.Type == fftypes.TokenTypeFungible && p.TransactionID == nil && p.Event.ProtocolID == "" + return p.ProtocolID == "F1" && p.Type == fftypes.TokenTypeFungible && p.TX.ID == nil && p.Event.ProtocolID == "" })).Return(nil) complete, err := h.ActivateTokenPool(context.Background(), opID, pool, txInfo) @@ -438,7 +441,10 @@ func TestMintTokens(t *testing.T) { "amount": "10", "signer": "0x123", "requestId": opID.String(), - "data": `{"tx":"` + mint.TX.ID.String() + `"}`, + "data": fftypes.JSONObject{ + "tx": mint.TX.ID.String(), + "txtype": fftypes.TransactionTypeTokenTransfer.String(), + }.String(), }, body) res := &http.Response{ @@ -488,7 +494,10 @@ func TestTokenApproval(t *testing.T) { "foo": "bar", }, "requestId": opID.String(), - "data": `{"tx":"` + approval.TX.ID.String() + `"}`, + "data": fftypes.JSONObject{ + "tx": approval.TX.ID.String(), + "txtype": fftypes.TransactionTypeTokenApproval.String(), + }.String(), }, body) res := &http.Response{ @@ -560,7 +569,10 @@ func TestBurnTokens(t *testing.T) { "amount": "10", "signer": "0x123", "requestId": opID.String(), - "data": `{"tx":"` + burn.TX.ID.String() + `"}`, + "data": fftypes.JSONObject{ + "tx": burn.TX.ID.String(), + "txtype": fftypes.TransactionTypeTokenTransfer.String(), + }.String(), }, body) res := &http.Response{ @@ -621,7 +633,10 @@ func TestTransferTokens(t *testing.T) { "amount": "10", "signer": "0x123", "requestId": opID.String(), - "data": `{"tx":"` + transfer.TX.ID.String() + `"}`, + "data": fftypes.JSONObject{ + "tx": transfer.TX.ID.String(), + "txtype": fftypes.TransactionTypeTokenTransfer.String(), + }.String(), }, body) res := &http.Response{ @@ -714,7 +729,7 @@ func TestEvents(t *testing.T) { // token-pool: invalid uuid (success) mcb.On("TokenPoolCreated", h, mock.MatchedBy(func(p *tokens.TokenPool) bool { - return p.ProtocolID == "F1" && p.Type == fftypes.TokenTypeFungible && p.TransactionID == nil && p.Event.ProtocolID == "000000000010/000020/000030/000040" + return p.ProtocolID == "F1" && p.Type == fftypes.TokenTypeFungible && p.TX.ID == nil && p.Event.ProtocolID == "000000000010/000020/000030/000040" })).Return(nil).Once() fromServer <- fftypes.JSONObject{ "id": "7", @@ -735,7 +750,7 @@ func TestEvents(t *testing.T) { // token-pool: success mcb.On("TokenPoolCreated", h, mock.MatchedBy(func(p *tokens.TokenPool) bool { - return p.ProtocolID == "F1" && p.Type == fftypes.TokenTypeFungible && txID.Equals(p.TransactionID) && p.Event.ProtocolID == "000000000010/000020/000030/000040" + return p.ProtocolID == "F1" && p.Type == fftypes.TokenTypeFungible && txID.Equals(p.TX.ID) && p.Event.ProtocolID == "000000000010/000020/000030/000040" })).Return(nil).Once() fromServer <- fftypes.JSONObject{ "id": "8", diff --git a/pkg/tokens/plugin.go b/pkg/tokens/plugin.go index 971edaac4..6bd705fb0 100644 --- a/pkg/tokens/plugin.go +++ b/pkg/tokens/plugin.go @@ -104,9 +104,8 @@ type TokenPool struct { // ProtocolID is the ID assigned to this pool by the connector (must be unique for this connector) ProtocolID string - // TransactionID is the FireFly-assigned ID to correlate this to a transaction (optional) - // Not guaranteed to be set for pool creation events triggered outside of FireFly - TransactionID *fftypes.UUID + // TX is the FireFly-assigned information to correlate this to a transaction (optional) + TX fftypes.TransactionRef // Connector is the configured name of this connector Connector string From f94f5dcfa2d70a0941ee3d603fca5d2b014a9bf4 Mon Sep 17 00:00:00 2001 From: Andrew Richardson Date: Thu, 17 Mar 2022 17:53:39 -0400 Subject: [PATCH 2/5] Add E2E test support for ERC20/ERC721 Resolves #564 Signed-off-by: Andrew Richardson --- .github/workflows/go.yml | 6 + manifest.json | 2 +- test/data/erc20/ERC20WithData.json | 489 +++++++++++++++++++++++ test/data/erc721/ERC721WithData.json | 572 +++++++++++++++++++++++++++ test/e2e/e2e_test.go | 1 - test/e2e/run.sh | 12 +- test/e2e/stack.go | 1 + test/e2e/tokens_test.go | 69 +++- 8 files changed, 1131 insertions(+), 21 deletions(-) create mode 100644 test/data/erc20/ERC20WithData.json create mode 100644 test/data/erc721/ERC721WithData.json diff --git a/.github/workflows/go.yml b/.github/workflows/go.yml index 779cd5bc6..39ce7dcdd 100644 --- a/.github/workflows/go.yml +++ b/.github/workflows/go.yml @@ -32,12 +32,17 @@ jobs: matrix: test-suite: [TestEthereumE2ESuite, TestFabricE2ESuite] blockchain-provider: [geth, fabric] + token-provider: [none, erc1155, erc20_erc721] database-type: [sqlite3] exclude: - blockchain-provider: geth test-suite: TestFabricE2ESuite - blockchain-provider: fabric test-suite: TestEthereumE2ESuite + - blockchain-provider: fabric + token-provider: erc20_erc721 + - blockchain-provider: geth + token-provider: none fail-fast: false steps: - uses: actions/checkout@v2 @@ -53,6 +58,7 @@ jobs: env: TEST_SUITE: ${{ matrix.test-suite }} BLOCKCHAIN_PROVIDER: ${{ matrix.blockchain-provider }} + TOKENS_PROVIDER: ${{ matrix.token-provider }} DATABASE_TYPE: ${{ matrix.database-type }} run: ./test/e2e/run.sh diff --git a/manifest.json b/manifest.json index 3e9355e5f..775fe36ed 100644 --- a/manifest.json +++ b/manifest.json @@ -46,4 +46,4 @@ "cli": { "tag": "v0.0.45" } -} \ No newline at end of file +} diff --git a/test/data/erc20/ERC20WithData.json b/test/data/erc20/ERC20WithData.json new file mode 100644 index 000000000..9e6842873 --- /dev/null +++ b/test/data/erc20/ERC20WithData.json @@ -0,0 +1,489 @@ +{ + "contracts": { + "contracts/ERC20WithData.sol:ERC20WithData": { + "abi": [ + { + "inputs": [], + "stateMutability": "nonpayable", + "type": "constructor" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "owner", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "spender", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "value", + "type": "uint256" + } + ], + "name": "Approval", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "previousOwner", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "newOwner", + "type": "address" + } + ], + "name": "OwnershipTransferred", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "from", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "to", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "value", + "type": "uint256" + } + ], + "name": "Transfer", + "type": "event" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "owner", + "type": "address" + }, + { + "internalType": "address", + "name": "spender", + "type": "address" + } + ], + "name": "allowance", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "spender", + "type": "address" + }, + { + "internalType": "uint256", + "name": "amount", + "type": "uint256" + } + ], + "name": "approve", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "spender", + "type": "address" + }, + { + "internalType": "uint256", + "name": "amount", + "type": "uint256" + }, + { + "internalType": "bytes", + "name": "", + "type": "bytes" + } + ], + "name": "approveWithData", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "account", + "type": "address" + } + ], + "name": "balanceOf", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "from", + "type": "address" + }, + { + "internalType": "uint256", + "name": "amount", + "type": "uint256" + }, + { + "internalType": "bytes", + "name": "", + "type": "bytes" + } + ], + "name": "burnWithData", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "decimals", + "outputs": [ + { + "internalType": "uint8", + "name": "", + "type": "uint8" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "spender", + "type": "address" + }, + { + "internalType": "uint256", + "name": "subtractedValue", + "type": "uint256" + } + ], + "name": "decreaseAllowance", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "spender", + "type": "address" + }, + { + "internalType": "uint256", + "name": "addedValue", + "type": "uint256" + } + ], + "name": "increaseAllowance", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "to", + "type": "address" + }, + { + "internalType": "uint256", + "name": "amount", + "type": "uint256" + }, + { + "internalType": "bytes", + "name": "", + "type": "bytes" + } + ], + "name": "mintWithData", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "name", + "outputs": [ + { + "internalType": "string", + "name": "", + "type": "string" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "owner", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "renounceOwnership", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "symbol", + "outputs": [ + { + "internalType": "string", + "name": "", + "type": "string" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "totalSupply", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "recipient", + "type": "address" + }, + { + "internalType": "uint256", + "name": "amount", + "type": "uint256" + } + ], + "name": "transfer", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "sender", + "type": "address" + }, + { + "internalType": "address", + "name": "recipient", + "type": "address" + }, + { + "internalType": "uint256", + "name": "amount", + "type": "uint256" + } + ], + "name": "transferFrom", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "newOwner", + "type": "address" + } + ], + "name": "transferOwnership", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "from", + "type": "address" + }, + { + "internalType": "address", + "name": "to", + "type": "address" + }, + { + "internalType": "uint256", + "name": "amount", + "type": "uint256" + }, + { + "internalType": "bytes", + "name": "", + "type": "bytes" + } + ], + "name": "transferWithData", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + } + ], + "bin": "60806040523480156200001157600080fd5b506040518060400160405280600981526020017f6532652d657263323000000000000000000000000000000000000000000000008152506040518060400160405280600481526020017f45453230000000000000000000000000000000000000000000000000000000008152506200009e62000092620000d860201b60201c565b620000e060201b60201c565b8160049080519060200190620000b6929190620001a4565b508060059080519060200190620000cf929190620001a4565b505050620002b8565b600033905090565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff169050816000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055508173ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a35050565b828054620001b29062000283565b90600052602060002090601f016020900481019282620001d6576000855562000222565b82601f10620001f157805160ff191683800117855562000222565b8280016001018555821562000222579182015b828111156200022157825182559160200191906001019062000204565b5b50905062000231919062000235565b5090565b5b808211156200025057600081600090555060010162000236565b5090565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052602260045260246000fd5b600060028204905060018216806200029c57607f821691505b602082108103620002b257620002b162000254565b5b50919050565b6120eb80620002c86000396000f3fe608060405234801561001057600080fd5b50600436106101165760003560e01c806383e49c53116100a2578063a457c2d711610071578063a457c2d7146102e3578063a9059cbb14610313578063c0ea7a7a14610343578063dd62ed3e1461035f578063f2fde38b1461038f57610116565b806383e49c531461026f5780638da5cb5b1461028b57806395d89b41146102a957806396adfe42146102c757610116565b8063313ce567116100e9578063313ce567146101b757806339509351146101d557806370a0823114610205578063715018a6146102355780637b5eb5641461023f57610116565b806306fdde031461011b578063095ea7b31461013957806318160ddd1461016957806323b872dd14610187575b600080fd5b6101236103ab565b604051610130919061149c565b60405180910390f35b610153600480360381019061014e919061155c565b61043d565b60405161016091906115b7565b60405180910390f35b61017161045b565b60405161017e91906115e1565b60405180910390f35b6101a1600480360381019061019c91906115fc565b610465565b6040516101ae91906115b7565b60405180910390f35b6101bf61055d565b6040516101cc919061166b565b60405180910390f35b6101ef60048036038101906101ea919061155c565b610566565b6040516101fc91906115b7565b60405180910390f35b61021f600480360381019061021a9190611686565b610612565b60405161022c91906115e1565b60405180910390f35b61023d61065b565b005b61025960048036038101906102549190611718565b6106e3565b60405161026691906115b7565b60405180910390f35b61028960048036038101906102849190611718565b6106f9565b005b61029361077e565b6040516102a0919061179b565b60405180910390f35b6102b16107a7565b6040516102be919061149c565b60405180910390f35b6102e160048036038101906102dc9190611718565b610839565b005b6102fd60048036038101906102f8919061155c565b6108c5565b60405161030a91906115b7565b60405180910390f35b61032d6004803603810190610328919061155c565b6109b0565b60405161033a91906115b7565b60405180910390f35b61035d600480360381019061035891906117b6565b6109ce565b005b6103796004803603810190610374919061183e565b610a2c565b60405161038691906115e1565b60405180910390f35b6103a960048036038101906103a49190611686565b610ab3565b005b6060600480546103ba906118ad565b80601f01602080910402602001604051908101604052809291908181526020018280546103e6906118ad565b80156104335780601f1061040857610100808354040283529160200191610433565b820191906000526020600020905b81548152906001019060200180831161041657829003601f168201915b5050505050905090565b600061045161044a610baa565b8484610bb2565b6001905092915050565b6000600354905090565b6000610472848484610d7b565b6000600260008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006104bd610baa565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205490508281101561053d576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161053490611950565b60405180910390fd5b61055185610549610baa565b858403610bb2565b60019150509392505050565b60006012905090565b6000610608610573610baa565b848460026000610581610baa565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008873ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054610603919061199f565b610bb2565b6001905092915050565b6000600160008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050919050565b610663610baa565b73ffffffffffffffffffffffffffffffffffffffff1661068161077e565b73ffffffffffffffffffffffffffffffffffffffff16146106d7576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016106ce90611a41565b60405180910390fd5b6106e16000610ffd565b565b60006106ef858561043d565b9050949350505050565b610701610baa565b73ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff161461076e576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161076590611ad3565b60405180910390fd5b61077884846110c1565b50505050565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b6060600580546107b6906118ad565b80601f01602080910402602001604051908101604052809291908181526020018280546107e2906118ad565b801561082f5780601f106108045761010080835404028352916020019161082f565b820191906000526020600020905b81548152906001019060200180831161081257829003601f168201915b5050505050905090565b610841610baa565b73ffffffffffffffffffffffffffffffffffffffff1661085f61077e565b73ffffffffffffffffffffffffffffffffffffffff16146108b5576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016108ac90611a41565b60405180910390fd5b6108bf8484611299565b50505050565b600080600260006108d4610baa565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905082811015610991576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161098890611b65565b60405180910390fd5b6109a561099c610baa565b85858403610bb2565b600191505092915050565b60006109c46109bd610baa565b8484610d7b565b6001905092915050565b6109d6610baa565b73ffffffffffffffffffffffffffffffffffffffff168573ffffffffffffffffffffffffffffffffffffffff1603610a1857610a1284846109b0565b50610a25565b610a23858585610465565b505b5050505050565b6000600260008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905092915050565b610abb610baa565b73ffffffffffffffffffffffffffffffffffffffff16610ad961077e565b73ffffffffffffffffffffffffffffffffffffffff1614610b2f576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610b2690611a41565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff1603610b9e576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610b9590611bf7565b60405180910390fd5b610ba781610ffd565b50565b600033905090565b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff1603610c21576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610c1890611c89565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1603610c90576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610c8790611d1b565b60405180910390fd5b80600260008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92583604051610d6e91906115e1565b60405180910390a3505050565b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff1603610dea576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610de190611dad565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1603610e59576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610e5090611e3f565b60405180910390fd5b610e648383836113f9565b6000600160008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905081811015610eeb576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610ee290611ed1565b60405180910390fd5b818103600160008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208190555081600160008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000828254610f80919061199f565b925050819055508273ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef84604051610fe491906115e1565b60405180910390a3610ff78484846113fe565b50505050565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff169050816000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055508173ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a35050565b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1603611130576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161112790611f63565b60405180910390fd5b61113c826000836113f9565b6000600160008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050818110156111c3576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016111ba90611ff5565b60405180910390fd5b818103600160008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550816003600082825461121b9190612015565b92505081905550600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef8460405161128091906115e1565b60405180910390a3611294836000846113fe565b505050565b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1603611308576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016112ff90612095565b60405180910390fd5b611314600083836113f9565b8060036000828254611326919061199f565b9250508190555080600160008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600082825461137c919061199f565b925050819055508173ffffffffffffffffffffffffffffffffffffffff16600073ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef836040516113e191906115e1565b60405180910390a36113f5600083836113fe565b5050565b505050565b505050565b600081519050919050565b600082825260208201905092915050565b60005b8381101561143d578082015181840152602081019050611422565b8381111561144c576000848401525b50505050565b6000601f19601f8301169050919050565b600061146e82611403565b611478818561140e565b935061148881856020860161141f565b61149181611452565b840191505092915050565b600060208201905081810360008301526114b68184611463565b905092915050565b600080fd5b600080fd5b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b60006114f3826114c8565b9050919050565b611503816114e8565b811461150e57600080fd5b50565b600081359050611520816114fa565b92915050565b6000819050919050565b61153981611526565b811461154457600080fd5b50565b60008135905061155681611530565b92915050565b60008060408385031215611573576115726114be565b5b600061158185828601611511565b925050602061159285828601611547565b9150509250929050565b60008115159050919050565b6115b18161159c565b82525050565b60006020820190506115cc60008301846115a8565b92915050565b6115db81611526565b82525050565b60006020820190506115f660008301846115d2565b92915050565b600080600060608486031215611615576116146114be565b5b600061162386828701611511565b935050602061163486828701611511565b925050604061164586828701611547565b9150509250925092565b600060ff82169050919050565b6116658161164f565b82525050565b6000602082019050611680600083018461165c565b92915050565b60006020828403121561169c5761169b6114be565b5b60006116aa84828501611511565b91505092915050565b600080fd5b600080fd5b600080fd5b60008083601f8401126116d8576116d76116b3565b5b8235905067ffffffffffffffff8111156116f5576116f46116b8565b5b602083019150836001820283011115611711576117106116bd565b5b9250929050565b60008060008060608587031215611732576117316114be565b5b600061174087828801611511565b945050602061175187828801611547565b935050604085013567ffffffffffffffff811115611772576117716114c3565b5b61177e878288016116c2565b925092505092959194509250565b611795816114e8565b82525050565b60006020820190506117b0600083018461178c565b92915050565b6000806000806000608086880312156117d2576117d16114be565b5b60006117e088828901611511565b95505060206117f188828901611511565b945050604061180288828901611547565b935050606086013567ffffffffffffffff811115611823576118226114c3565b5b61182f888289016116c2565b92509250509295509295909350565b60008060408385031215611855576118546114be565b5b600061186385828601611511565b925050602061187485828601611511565b9150509250929050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052602260045260246000fd5b600060028204905060018216806118c557607f821691505b6020821081036118d8576118d761187e565b5b50919050565b7f45524332303a207472616e7366657220616d6f756e742065786365656473206160008201527f6c6c6f77616e6365000000000000000000000000000000000000000000000000602082015250565b600061193a60288361140e565b9150611945826118de565b604082019050919050565b600060208201905081810360008301526119698161192d565b9050919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b60006119aa82611526565b91506119b583611526565b9250827fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff038211156119ea576119e9611970565b5b828201905092915050565b7f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572600082015250565b6000611a2b60208361140e565b9150611a36826119f5565b602082019050919050565b60006020820190508181036000830152611a5a81611a1e565b9050919050565b7f455243323057697468446174613a2063616c6c6572206973206e6f74206f776e60008201527f6572000000000000000000000000000000000000000000000000000000000000602082015250565b6000611abd60228361140e565b9150611ac882611a61565b604082019050919050565b60006020820190508181036000830152611aec81611ab0565b9050919050565b7f45524332303a2064656372656173656420616c6c6f77616e63652062656c6f7760008201527f207a65726f000000000000000000000000000000000000000000000000000000602082015250565b6000611b4f60258361140e565b9150611b5a82611af3565b604082019050919050565b60006020820190508181036000830152611b7e81611b42565b9050919050565b7f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160008201527f6464726573730000000000000000000000000000000000000000000000000000602082015250565b6000611be160268361140e565b9150611bec82611b85565b604082019050919050565b60006020820190508181036000830152611c1081611bd4565b9050919050565b7f45524332303a20617070726f76652066726f6d20746865207a65726f2061646460008201527f7265737300000000000000000000000000000000000000000000000000000000602082015250565b6000611c7360248361140e565b9150611c7e82611c17565b604082019050919050565b60006020820190508181036000830152611ca281611c66565b9050919050565b7f45524332303a20617070726f766520746f20746865207a65726f20616464726560008201527f7373000000000000000000000000000000000000000000000000000000000000602082015250565b6000611d0560228361140e565b9150611d1082611ca9565b604082019050919050565b60006020820190508181036000830152611d3481611cf8565b9050919050565b7f45524332303a207472616e736665722066726f6d20746865207a65726f20616460008201527f6472657373000000000000000000000000000000000000000000000000000000602082015250565b6000611d9760258361140e565b9150611da282611d3b565b604082019050919050565b60006020820190508181036000830152611dc681611d8a565b9050919050565b7f45524332303a207472616e7366657220746f20746865207a65726f206164647260008201527f6573730000000000000000000000000000000000000000000000000000000000602082015250565b6000611e2960238361140e565b9150611e3482611dcd565b604082019050919050565b60006020820190508181036000830152611e5881611e1c565b9050919050565b7f45524332303a207472616e7366657220616d6f756e742065786365656473206260008201527f616c616e63650000000000000000000000000000000000000000000000000000602082015250565b6000611ebb60268361140e565b9150611ec682611e5f565b604082019050919050565b60006020820190508181036000830152611eea81611eae565b9050919050565b7f45524332303a206275726e2066726f6d20746865207a65726f2061646472657360008201527f7300000000000000000000000000000000000000000000000000000000000000602082015250565b6000611f4d60218361140e565b9150611f5882611ef1565b604082019050919050565b60006020820190508181036000830152611f7c81611f40565b9050919050565b7f45524332303a206275726e20616d6f756e7420657863656564732062616c616e60008201527f6365000000000000000000000000000000000000000000000000000000000000602082015250565b6000611fdf60228361140e565b9150611fea82611f83565b604082019050919050565b6000602082019050818103600083015261200e81611fd2565b9050919050565b600061202082611526565b915061202b83611526565b92508282101561203e5761203d611970565b5b828203905092915050565b7f45524332303a206d696e7420746f20746865207a65726f206164647265737300600082015250565b600061207f601f8361140e565b915061208a82612049565b602082019050919050565b600060208201905081810360008301526120ae81612072565b905091905056fea2646970667358221220aae08d74316893d58e8a79f83b11a7962df6b7e5d2ba6e8e6859b0e12c83b92f64736f6c634300080d0033", + "devdoc": { + "details": "Mintable+burnable form of ERC20 with data event support.", + "kind": "dev", + "methods": { + "allowance(address,address)": { + "details": "See {IERC20-allowance}." + }, + "approve(address,uint256)": { + "details": "See {IERC20-approve}. Requirements: - `spender` cannot be the zero address." + }, + "balanceOf(address)": { + "details": "See {IERC20-balanceOf}." + }, + "decimals()": { + "details": "Returns the number of decimals used to get its user representation. For example, if `decimals` equals `2`, a balance of `505` tokens should be displayed to a user as `5.05` (`505 / 10 ** 2`). Tokens usually opt for a value of 18, imitating the relationship between Ether and Wei. This is the value {ERC20} uses, unless this function is overridden; NOTE: This information is only used for _display_ purposes: it in no way affects any of the arithmetic of the contract, including {IERC20-balanceOf} and {IERC20-transfer}." + }, + "decreaseAllowance(address,uint256)": { + "details": "Atomically decreases the allowance granted to `spender` by the caller. This is an alternative to {approve} that can be used as a mitigation for problems described in {IERC20-approve}. Emits an {Approval} event indicating the updated allowance. Requirements: - `spender` cannot be the zero address. - `spender` must have allowance for the caller of at least `subtractedValue`." + }, + "increaseAllowance(address,uint256)": { + "details": "Atomically increases the allowance granted to `spender` by the caller. This is an alternative to {approve} that can be used as a mitigation for problems described in {IERC20-approve}. Emits an {Approval} event indicating the updated allowance. Requirements: - `spender` cannot be the zero address." + }, + "name()": { + "details": "Returns the name of the token." + }, + "owner()": { + "details": "Returns the address of the current owner." + }, + "renounceOwnership()": { + "details": "Leaves the contract without owner. It will not be possible to call `onlyOwner` functions anymore. Can only be called by the current owner. NOTE: Renouncing ownership will leave the contract without an owner, thereby removing any functionality that is only available to the owner." + }, + "symbol()": { + "details": "Returns the symbol of the token, usually a shorter version of the name." + }, + "totalSupply()": { + "details": "See {IERC20-totalSupply}." + }, + "transfer(address,uint256)": { + "details": "See {IERC20-transfer}. Requirements: - `recipient` cannot be the zero address. - the caller must have a balance of at least `amount`." + }, + "transferFrom(address,address,uint256)": { + "details": "See {IERC20-transferFrom}. Emits an {Approval} event indicating the updated allowance. This is not required by the EIP. See the note at the beginning of {ERC20}. Requirements: - `sender` and `recipient` cannot be the zero address. - `sender` must have a balance of at least `amount`. - the caller must have allowance for ``sender``'s tokens of at least `amount`." + }, + "transferOwnership(address)": { + "details": "Transfers ownership of the contract to a new account (`newOwner`). Can only be called by the current owner." + } + }, + "version": 1 + } + } + }, + "version": "0.8.13+commit.abaa5c0e.Darwin.appleclang" +} \ No newline at end of file diff --git a/test/data/erc721/ERC721WithData.json b/test/data/erc721/ERC721WithData.json new file mode 100644 index 000000000..db954e86b --- /dev/null +++ b/test/data/erc721/ERC721WithData.json @@ -0,0 +1,572 @@ +{ + "contracts": { + "contracts/ERC721WithData.sol:ERC721WithData": { + "abi": [ + { + "inputs": [], + "stateMutability": "nonpayable", + "type": "constructor" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "owner", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "approved", + "type": "address" + }, + { + "indexed": true, + "internalType": "uint256", + "name": "tokenId", + "type": "uint256" + } + ], + "name": "Approval", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "owner", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "operator", + "type": "address" + }, + { + "indexed": false, + "internalType": "bool", + "name": "approved", + "type": "bool" + } + ], + "name": "ApprovalForAll", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "previousOwner", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "newOwner", + "type": "address" + } + ], + "name": "OwnershipTransferred", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "from", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "to", + "type": "address" + }, + { + "indexed": true, + "internalType": "uint256", + "name": "tokenId", + "type": "uint256" + } + ], + "name": "Transfer", + "type": "event" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "to", + "type": "address" + }, + { + "internalType": "uint256", + "name": "tokenId", + "type": "uint256" + } + ], + "name": "approve", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "to", + "type": "address" + }, + { + "internalType": "uint256", + "name": "tokenId", + "type": "uint256" + }, + { + "internalType": "bytes", + "name": "", + "type": "bytes" + } + ], + "name": "approveWithData", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "owner", + "type": "address" + } + ], + "name": "balanceOf", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "from", + "type": "address" + }, + { + "internalType": "uint256", + "name": "tokenId", + "type": "uint256" + }, + { + "internalType": "bytes", + "name": "", + "type": "bytes" + } + ], + "name": "burnWithData", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "tokenId", + "type": "uint256" + } + ], + "name": "getApproved", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "owner", + "type": "address" + }, + { + "internalType": "address", + "name": "operator", + "type": "address" + } + ], + "name": "isApprovedForAll", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "to", + "type": "address" + }, + { + "internalType": "uint256", + "name": "tokenId", + "type": "uint256" + }, + { + "internalType": "bytes", + "name": "data", + "type": "bytes" + } + ], + "name": "mintWithData", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "name", + "outputs": [ + { + "internalType": "string", + "name": "", + "type": "string" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "owner", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "tokenId", + "type": "uint256" + } + ], + "name": "ownerOf", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "renounceOwnership", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "from", + "type": "address" + }, + { + "internalType": "address", + "name": "to", + "type": "address" + }, + { + "internalType": "uint256", + "name": "tokenId", + "type": "uint256" + } + ], + "name": "safeTransferFrom", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "from", + "type": "address" + }, + { + "internalType": "address", + "name": "to", + "type": "address" + }, + { + "internalType": "uint256", + "name": "tokenId", + "type": "uint256" + }, + { + "internalType": "bytes", + "name": "_data", + "type": "bytes" + } + ], + "name": "safeTransferFrom", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "operator", + "type": "address" + }, + { + "internalType": "bool", + "name": "approved", + "type": "bool" + } + ], + "name": "setApprovalForAll", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "operator", + "type": "address" + }, + { + "internalType": "bool", + "name": "approved", + "type": "bool" + }, + { + "internalType": "bytes", + "name": "", + "type": "bytes" + } + ], + "name": "setApprovalForAllWithData", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bytes4", + "name": "interfaceId", + "type": "bytes4" + } + ], + "name": "supportsInterface", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "symbol", + "outputs": [ + { + "internalType": "string", + "name": "", + "type": "string" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "tokenId", + "type": "uint256" + } + ], + "name": "tokenURI", + "outputs": [ + { + "internalType": "string", + "name": "", + "type": "string" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "from", + "type": "address" + }, + { + "internalType": "address", + "name": "to", + "type": "address" + }, + { + "internalType": "uint256", + "name": "tokenId", + "type": "uint256" + } + ], + "name": "transferFrom", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "newOwner", + "type": "address" + } + ], + "name": "transferOwnership", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "from", + "type": "address" + }, + { + "internalType": "address", + "name": "to", + "type": "address" + }, + { + "internalType": "uint256", + "name": "tokenId", + "type": "uint256" + }, + { + "internalType": "bytes", + "name": "data", + "type": "bytes" + } + ], + "name": "transferWithData", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + } + ], + "bin": "60806040523480156200001157600080fd5b506040518060400160405280600a81526020017f6532652d657263373231000000000000000000000000000000000000000000008152506040518060400160405280600581526020017f45453732310000000000000000000000000000000000000000000000000000008152506200009e62000092620000d860201b60201c565b620000e060201b60201c565b8160019080519060200190620000b6929190620001a4565b508060029080519060200190620000cf929190620001a4565b505050620002b8565b600033905090565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff169050816000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055508173ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a35050565b828054620001b29062000283565b90600052602060002090601f016020900481019282620001d6576000855562000222565b82601f10620001f157805160ff191683800117855562000222565b8280016001018555821562000222579182015b828111156200022157825182559160200191906001019062000204565b5b50905062000231919062000235565b5090565b5b808211156200025057600081600090555060010162000236565b5090565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052602260045260246000fd5b600060028204905060018216806200029c57607f821691505b602082108103620002b257620002b162000254565b5b50919050565b6130bd80620002c86000396000f3fe608060405234801561001057600080fd5b50600436106101375760003560e01c80637b5eb564116100b8578063a22cb4651161007c578063a22cb46514610324578063b88d4fde14610340578063c0ea7a7a1461035c578063c87b56dd14610378578063e985e9c5146103a8578063f2fde38b146103d857610137565b80637b5eb5641461029457806383e49c53146102b05780638da5cb5b146102cc57806395d89b41146102ea57806396adfe421461030857610137565b806323b872dd116100ff57806323b872dd146101f257806342842e0e1461020e5780636352211e1461022a57806370a082311461025a578063715018a61461028a57610137565b806301ffc9a71461013c57806306fdde031461016c578063081812fc1461018a578063095ea7b3146101ba5780631cbf311d146101d6575b600080fd5b61015660048036038101906101519190611ce2565b6103f4565b6040516101639190611d2a565b60405180910390f35b6101746104d6565b6040516101819190611dde565b60405180910390f35b6101a4600480360381019061019f9190611e36565b610568565b6040516101b19190611ea4565b60405180910390f35b6101d460048036038101906101cf9190611eeb565b6105ed565b005b6101f060048036038101906101eb9190611fbc565b610704565b005b61020c60048036038101906102079190612030565b610714565b005b61022860048036038101906102239190612030565b610774565b005b610244600480360381019061023f9190611e36565b610794565b6040516102519190611ea4565b60405180910390f35b610274600480360381019061026f9190612083565b610845565b60405161028191906120bf565b60405180910390f35b6102926108fc565b005b6102ae60048036038101906102a991906120da565b610984565b005b6102ca60048036038101906102c591906120da565b610994565b005b6102d4610a18565b6040516102e19190611ea4565b60405180910390f35b6102f2610a41565b6040516102ff9190611dde565b60405180910390f35b610322600480360381019061031d91906120da565b610ad3565b005b61033e6004803603810190610339919061214e565b610ba4565b005b61035a600480360381019061035591906122be565b610bba565b005b61037660048036038101906103719190612341565b610c1c565b005b610392600480360381019061038d9190611e36565b610c73565b60405161039f9190611dde565b60405180910390f35b6103c260048036038101906103bd91906123c9565b610d1a565b6040516103cf9190611d2a565b60405180910390f35b6103f260048036038101906103ed9190612083565b610dae565b005b60007f80ac58cd000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff191614806104bf57507f5b5e139f000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916145b806104cf57506104ce82610ea5565b5b9050919050565b6060600180546104e590612438565b80601f016020809104026020016040519081016040528092919081815260200182805461051190612438565b801561055e5780601f106105335761010080835404028352916020019161055e565b820191906000526020600020905b81548152906001019060200180831161054157829003601f168201915b5050505050905090565b600061057382610f0f565b6105b2576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016105a9906124db565b60405180910390fd5b6005600083815260200190815260200160002060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff169050919050565b60006105f882610794565b90508073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff1603610668576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161065f9061256d565b60405180910390fd5b8073ffffffffffffffffffffffffffffffffffffffff16610687610f7b565b73ffffffffffffffffffffffffffffffffffffffff1614806106b657506106b5816106b0610f7b565b610d1a565b5b6106f5576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016106ec906125ff565b60405180910390fd5b6106ff8383610f83565b505050565b61070e8484610ba4565b50505050565b61072561071f610f7b565b8261103c565b610764576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161075b90612691565b60405180910390fd5b61076f83838361111a565b505050565b61078f83838360405180602001604052806000815250610bba565b505050565b6000806003600084815260200190815260200160002060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff169050600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff160361083c576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161083390612723565b60405180910390fd5b80915050919050565b60008073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff16036108b5576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016108ac906127b5565b60405180910390fd5b600460008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050919050565b610904610f7b565b73ffffffffffffffffffffffffffffffffffffffff16610922610a18565b73ffffffffffffffffffffffffffffffffffffffff1614610978576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161096f90612821565b60405180910390fd5b6109826000611375565b565b61098e84846105ed565b50505050565b61099c610f7b565b73ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff1614610a09576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610a00906128b3565b60405180910390fd5b610a1283611439565b50505050565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b606060028054610a5090612438565b80601f0160208091040260200160405190810160405280929190818152602001828054610a7c90612438565b8015610ac95780601f10610a9e57610100808354040283529160200191610ac9565b820191906000526020600020905b815481529060010190602001808311610aac57829003601f168201915b5050505050905090565b610adb610f7b565b73ffffffffffffffffffffffffffffffffffffffff16610af9610a18565b73ffffffffffffffffffffffffffffffffffffffff1614610b4f576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610b4690612821565b60405180910390fd5b610b9e848484848080601f016020809104026020016040519081016040528093929190818152602001838380828437600081840152601f19601f8201169050808301925050505050505061154a565b50505050565b610bb6610baf610f7b565b83836115a5565b5050565b610bcb610bc5610f7b565b8361103c565b610c0a576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610c0190612691565b60405180910390fd5b610c1684848484611711565b50505050565b610c6c85858585858080601f016020809104026020016040519081016040528093929190818152602001838380828437600081840152601f19601f82011690508083019250505050505050610bba565b5050505050565b6060610c7e82610f0f565b610cbd576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610cb490612945565b60405180910390fd5b6000610cc761176d565b90506000815111610ce75760405180602001604052806000815250610d12565b80610cf1846117aa565b604051602001610d029291906129a1565b6040516020818303038152906040525b915050919050565b6000600660008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16905092915050565b610db6610f7b565b73ffffffffffffffffffffffffffffffffffffffff16610dd4610a18565b73ffffffffffffffffffffffffffffffffffffffff1614610e2a576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610e2190612821565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff1603610e99576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610e9090612a37565b60405180910390fd5b610ea281611375565b50565b60007f01ffc9a7000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916149050919050565b60008073ffffffffffffffffffffffffffffffffffffffff166003600084815260200190815260200160002060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614159050919050565b600033905090565b816005600083815260200190815260200160002060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550808273ffffffffffffffffffffffffffffffffffffffff16610ff683610794565b73ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92560405160405180910390a45050565b600061104782610f0f565b611086576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161107d90612ac9565b60405180910390fd5b600061109183610794565b90508073ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff16148061110057508373ffffffffffffffffffffffffffffffffffffffff166110e884610568565b73ffffffffffffffffffffffffffffffffffffffff16145b8061111157506111108185610d1a565b5b91505092915050565b8273ffffffffffffffffffffffffffffffffffffffff1661113a82610794565b73ffffffffffffffffffffffffffffffffffffffff1614611190576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161118790612b5b565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff16036111ff576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016111f690612bed565b60405180910390fd5b61120a83838361190a565b611215600082610f83565b6001600460008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008282546112659190612c3c565b925050819055506001600460008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008282546112bc9190612c70565b92505081905550816003600083815260200190815260200160002060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550808273ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef60405160405180910390a4505050565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff169050816000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055508173ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a35050565b600061144482610794565b90506114528160008461190a565b61145d600083610f83565b6001600460008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008282546114ad9190612c3c565b925050819055506003600083815260200190815260200160002060006101000a81549073ffffffffffffffffffffffffffffffffffffffff021916905581600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef60405160405180910390a45050565b611554838361190f565b6115616000848484611adc565b6115a0576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161159790612d38565b60405180910390fd5b505050565b8173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff1603611613576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161160a90612da4565b60405180910390fd5b80600660008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff0219169083151502179055508173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff167f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c31836040516117049190611d2a565b60405180910390a3505050565b61171c84848461111a565b61172884848484611adc565b611767576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161175e90612d38565b60405180910390fd5b50505050565b60606040518060400160405280601081526020017f66697265666c793a2f2f746f6b656e2f00000000000000000000000000000000815250905090565b6060600082036117f1576040518060400160405280600181526020017f30000000000000000000000000000000000000000000000000000000000000008152509050611905565b600082905060005b6000821461182357808061180c90612dc4565b915050600a8261181c9190612e3b565b91506117f9565b60008167ffffffffffffffff81111561183f5761183e612193565b5b6040519080825280601f01601f1916602001820160405280156118715781602001600182028036833780820191505090505b5090505b600085146118fe5760018261188a9190612c3c565b9150600a856118999190612e6c565b60306118a59190612c70565b60f81b8183815181106118bb576118ba612e9d565b5b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a905350600a856118f79190612e3b565b9450611875565b8093505050505b919050565b505050565b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff160361197e576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161197590612f18565b60405180910390fd5b61198781610f0f565b156119c7576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016119be90612f84565b60405180910390fd5b6119d36000838361190a565b6001600460008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000828254611a239190612c70565b92505081905550816003600083815260200190815260200160002060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550808273ffffffffffffffffffffffffffffffffffffffff16600073ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef60405160405180910390a45050565b6000611afd8473ffffffffffffffffffffffffffffffffffffffff16611c63565b15611c56578373ffffffffffffffffffffffffffffffffffffffff1663150b7a02611b26610f7b565b8786866040518563ffffffff1660e01b8152600401611b489493929190612ff9565b6020604051808303816000875af1925050508015611b8457506040513d601f19601f82011682018060405250810190611b81919061305a565b60015b611c06573d8060008114611bb4576040519150601f19603f3d011682016040523d82523d6000602084013e611bb9565b606091505b506000815103611bfe576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611bf590612d38565b60405180910390fd5b805181602001fd5b63150b7a0260e01b7bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916817bffffffffffffffffffffffffffffffffffffffffffffffffffffffff191614915050611c5b565b600190505b949350505050565b600080823b905060008111915050919050565b6000604051905090565b600080fd5b600080fd5b60007fffffffff0000000000000000000000000000000000000000000000000000000082169050919050565b611cbf81611c8a565b8114611cca57600080fd5b50565b600081359050611cdc81611cb6565b92915050565b600060208284031215611cf857611cf7611c80565b5b6000611d0684828501611ccd565b91505092915050565b60008115159050919050565b611d2481611d0f565b82525050565b6000602082019050611d3f6000830184611d1b565b92915050565b600081519050919050565b600082825260208201905092915050565b60005b83811015611d7f578082015181840152602081019050611d64565b83811115611d8e576000848401525b50505050565b6000601f19601f8301169050919050565b6000611db082611d45565b611dba8185611d50565b9350611dca818560208601611d61565b611dd381611d94565b840191505092915050565b60006020820190508181036000830152611df88184611da5565b905092915050565b6000819050919050565b611e1381611e00565b8114611e1e57600080fd5b50565b600081359050611e3081611e0a565b92915050565b600060208284031215611e4c57611e4b611c80565b5b6000611e5a84828501611e21565b91505092915050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000611e8e82611e63565b9050919050565b611e9e81611e83565b82525050565b6000602082019050611eb96000830184611e95565b92915050565b611ec881611e83565b8114611ed357600080fd5b50565b600081359050611ee581611ebf565b92915050565b60008060408385031215611f0257611f01611c80565b5b6000611f1085828601611ed6565b9250506020611f2185828601611e21565b9150509250929050565b611f3481611d0f565b8114611f3f57600080fd5b50565b600081359050611f5181611f2b565b92915050565b600080fd5b600080fd5b600080fd5b60008083601f840112611f7c57611f7b611f57565b5b8235905067ffffffffffffffff811115611f9957611f98611f5c565b5b602083019150836001820283011115611fb557611fb4611f61565b5b9250929050565b60008060008060608587031215611fd657611fd5611c80565b5b6000611fe487828801611ed6565b9450506020611ff587828801611f42565b935050604085013567ffffffffffffffff81111561201657612015611c85565b5b61202287828801611f66565b925092505092959194509250565b60008060006060848603121561204957612048611c80565b5b600061205786828701611ed6565b935050602061206886828701611ed6565b925050604061207986828701611e21565b9150509250925092565b60006020828403121561209957612098611c80565b5b60006120a784828501611ed6565b91505092915050565b6120b981611e00565b82525050565b60006020820190506120d460008301846120b0565b92915050565b600080600080606085870312156120f4576120f3611c80565b5b600061210287828801611ed6565b945050602061211387828801611e21565b935050604085013567ffffffffffffffff81111561213457612133611c85565b5b61214087828801611f66565b925092505092959194509250565b6000806040838503121561216557612164611c80565b5b600061217385828601611ed6565b925050602061218485828601611f42565b9150509250929050565b600080fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b6121cb82611d94565b810181811067ffffffffffffffff821117156121ea576121e9612193565b5b80604052505050565b60006121fd611c76565b905061220982826121c2565b919050565b600067ffffffffffffffff82111561222957612228612193565b5b61223282611d94565b9050602081019050919050565b82818337600083830152505050565b600061226161225c8461220e565b6121f3565b90508281526020810184848401111561227d5761227c61218e565b5b61228884828561223f565b509392505050565b600082601f8301126122a5576122a4611f57565b5b81356122b584826020860161224e565b91505092915050565b600080600080608085870312156122d8576122d7611c80565b5b60006122e687828801611ed6565b94505060206122f787828801611ed6565b935050604061230887828801611e21565b925050606085013567ffffffffffffffff81111561232957612328611c85565b5b61233587828801612290565b91505092959194509250565b60008060008060006080868803121561235d5761235c611c80565b5b600061236b88828901611ed6565b955050602061237c88828901611ed6565b945050604061238d88828901611e21565b935050606086013567ffffffffffffffff8111156123ae576123ad611c85565b5b6123ba88828901611f66565b92509250509295509295909350565b600080604083850312156123e0576123df611c80565b5b60006123ee85828601611ed6565b92505060206123ff85828601611ed6565b9150509250929050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052602260045260246000fd5b6000600282049050600182168061245057607f821691505b60208210810361246357612462612409565b5b50919050565b7f4552433732313a20617070726f76656420717565727920666f72206e6f6e657860008201527f697374656e7420746f6b656e0000000000000000000000000000000000000000602082015250565b60006124c5602c83611d50565b91506124d082612469565b604082019050919050565b600060208201905081810360008301526124f4816124b8565b9050919050565b7f4552433732313a20617070726f76616c20746f2063757272656e74206f776e6560008201527f7200000000000000000000000000000000000000000000000000000000000000602082015250565b6000612557602183611d50565b9150612562826124fb565b604082019050919050565b600060208201905081810360008301526125868161254a565b9050919050565b7f4552433732313a20617070726f76652063616c6c6572206973206e6f74206f7760008201527f6e6572206e6f7220617070726f76656420666f7220616c6c0000000000000000602082015250565b60006125e9603883611d50565b91506125f48261258d565b604082019050919050565b60006020820190508181036000830152612618816125dc565b9050919050565b7f4552433732313a207472616e736665722063616c6c6572206973206e6f74206f60008201527f776e6572206e6f7220617070726f766564000000000000000000000000000000602082015250565b600061267b603183611d50565b91506126868261261f565b604082019050919050565b600060208201905081810360008301526126aa8161266e565b9050919050565b7f4552433732313a206f776e657220717565727920666f72206e6f6e657869737460008201527f656e7420746f6b656e0000000000000000000000000000000000000000000000602082015250565b600061270d602983611d50565b9150612718826126b1565b604082019050919050565b6000602082019050818103600083015261273c81612700565b9050919050565b7f4552433732313a2062616c616e636520717565727920666f7220746865207a6560008201527f726f206164647265737300000000000000000000000000000000000000000000602082015250565b600061279f602a83611d50565b91506127aa82612743565b604082019050919050565b600060208201905081810360008301526127ce81612792565b9050919050565b7f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572600082015250565b600061280b602083611d50565b9150612816826127d5565b602082019050919050565b6000602082019050818103600083015261283a816127fe565b9050919050565b7f45524337323157697468446174613a2063616c6c6572206973206e6f74206f7760008201527f6e65720000000000000000000000000000000000000000000000000000000000602082015250565b600061289d602383611d50565b91506128a882612841565b604082019050919050565b600060208201905081810360008301526128cc81612890565b9050919050565b7f4552433732314d657461646174613a2055524920717565727920666f72206e6f60008201527f6e6578697374656e7420746f6b656e0000000000000000000000000000000000602082015250565b600061292f602f83611d50565b915061293a826128d3565b604082019050919050565b6000602082019050818103600083015261295e81612922565b9050919050565b600081905092915050565b600061297b82611d45565b6129858185612965565b9350612995818560208601611d61565b80840191505092915050565b60006129ad8285612970565b91506129b98284612970565b91508190509392505050565b7f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160008201527f6464726573730000000000000000000000000000000000000000000000000000602082015250565b6000612a21602683611d50565b9150612a2c826129c5565b604082019050919050565b60006020820190508181036000830152612a5081612a14565b9050919050565b7f4552433732313a206f70657261746f7220717565727920666f72206e6f6e657860008201527f697374656e7420746f6b656e0000000000000000000000000000000000000000602082015250565b6000612ab3602c83611d50565b9150612abe82612a57565b604082019050919050565b60006020820190508181036000830152612ae281612aa6565b9050919050565b7f4552433732313a207472616e73666572206f6620746f6b656e2074686174206960008201527f73206e6f74206f776e0000000000000000000000000000000000000000000000602082015250565b6000612b45602983611d50565b9150612b5082612ae9565b604082019050919050565b60006020820190508181036000830152612b7481612b38565b9050919050565b7f4552433732313a207472616e7366657220746f20746865207a65726f2061646460008201527f7265737300000000000000000000000000000000000000000000000000000000602082015250565b6000612bd7602483611d50565b9150612be282612b7b565b604082019050919050565b60006020820190508181036000830152612c0681612bca565b9050919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b6000612c4782611e00565b9150612c5283611e00565b925082821015612c6557612c64612c0d565b5b828203905092915050565b6000612c7b82611e00565b9150612c8683611e00565b9250827fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff03821115612cbb57612cba612c0d565b5b828201905092915050565b7f4552433732313a207472616e7366657220746f206e6f6e20455243373231526560008201527f63656976657220696d706c656d656e7465720000000000000000000000000000602082015250565b6000612d22603283611d50565b9150612d2d82612cc6565b604082019050919050565b60006020820190508181036000830152612d5181612d15565b9050919050565b7f4552433732313a20617070726f766520746f2063616c6c657200000000000000600082015250565b6000612d8e601983611d50565b9150612d9982612d58565b602082019050919050565b60006020820190508181036000830152612dbd81612d81565b9050919050565b6000612dcf82611e00565b91507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8203612e0157612e00612c0d565b5b600182019050919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601260045260246000fd5b6000612e4682611e00565b9150612e5183611e00565b925082612e6157612e60612e0c565b5b828204905092915050565b6000612e7782611e00565b9150612e8283611e00565b925082612e9257612e91612e0c565b5b828206905092915050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b7f4552433732313a206d696e7420746f20746865207a65726f2061646472657373600082015250565b6000612f02602083611d50565b9150612f0d82612ecc565b602082019050919050565b60006020820190508181036000830152612f3181612ef5565b9050919050565b7f4552433732313a20746f6b656e20616c7265616479206d696e74656400000000600082015250565b6000612f6e601c83611d50565b9150612f7982612f38565b602082019050919050565b60006020820190508181036000830152612f9d81612f61565b9050919050565b600081519050919050565b600082825260208201905092915050565b6000612fcb82612fa4565b612fd58185612faf565b9350612fe5818560208601611d61565b612fee81611d94565b840191505092915050565b600060808201905061300e6000830187611e95565b61301b6020830186611e95565b61302860408301856120b0565b818103606083015261303a8184612fc0565b905095945050505050565b60008151905061305481611cb6565b92915050565b6000602082840312156130705761306f611c80565b5b600061307e84828501613045565b9150509291505056fea2646970667358221220d74d462d2b1ae886a3506b37c071c0c0b9289f82e1c9e7bbb77dc38a59ab6b6264736f6c634300080d0033", + "devdoc": { + "details": "Mintable+burnable form of ERC721 with data event support.", + "kind": "dev", + "methods": { + "approve(address,uint256)": { + "details": "See {IERC721-approve}." + }, + "balanceOf(address)": { + "details": "See {IERC721-balanceOf}." + }, + "getApproved(uint256)": { + "details": "See {IERC721-getApproved}." + }, + "isApprovedForAll(address,address)": { + "details": "See {IERC721-isApprovedForAll}." + }, + "name()": { + "details": "See {IERC721Metadata-name}." + }, + "owner()": { + "details": "Returns the address of the current owner." + }, + "ownerOf(uint256)": { + "details": "See {IERC721-ownerOf}." + }, + "renounceOwnership()": { + "details": "Leaves the contract without owner. It will not be possible to call `onlyOwner` functions anymore. Can only be called by the current owner. NOTE: Renouncing ownership will leave the contract without an owner, thereby removing any functionality that is only available to the owner." + }, + "safeTransferFrom(address,address,uint256)": { + "details": "See {IERC721-safeTransferFrom}." + }, + "safeTransferFrom(address,address,uint256,bytes)": { + "details": "See {IERC721-safeTransferFrom}." + }, + "setApprovalForAll(address,bool)": { + "details": "See {IERC721-setApprovalForAll}." + }, + "supportsInterface(bytes4)": { + "details": "See {IERC165-supportsInterface}." + }, + "symbol()": { + "details": "See {IERC721Metadata-symbol}." + }, + "tokenURI(uint256)": { + "details": "See {IERC721Metadata-tokenURI}." + }, + "transferFrom(address,address,uint256)": { + "details": "See {IERC721-transferFrom}." + }, + "transferOwnership(address)": { + "details": "Transfers ownership of the contract to a new account (`newOwner`). Can only be called by the current owner." + } + }, + "version": 1 + } + } + }, + "version": "0.8.13+commit.abaa5c0e.Darwin.appleclang" +} \ No newline at end of file diff --git a/test/e2e/e2e_test.go b/test/e2e/e2e_test.go index 56d7e398f..c3b731daf 100644 --- a/test/e2e/e2e_test.go +++ b/test/e2e/e2e_test.go @@ -137,7 +137,6 @@ func validateReceivedMessages(ts *testState, client *resty.Client, topic string, func validateAccountBalances(t *testing.T, client *resty.Client, poolID *fftypes.UUID, tokenIndex string, balances map[string]int64) { for key, balance := range balances { account := GetTokenBalance(t, client, poolID, tokenIndex, key) - assert.Equal(t, "erc1155", account.Connector) assert.Equal(t, balance, account.Balance.Int().Int64()) } } diff --git a/test/e2e/run.sh b/test/e2e/run.sh index db262b8ec..fcbc8c84e 100755 --- a/test/e2e/run.sh +++ b/test/e2e/run.sh @@ -90,11 +90,19 @@ if [ "$CREATE_STACK" == "true" ]; then if [ "$TEST_SUITE" == "TestEthereumE2ESuite" ]; then prefix='contract address: ' output=$($CLI deploy $STACK_NAME ../data/simplestorage/simple_storage.json | grep address) - CONTRACT_ADDRESS=${output#"$prefix"} - export CONTRACT_ADDRESS + export CONTRACT_ADDRESS=${output#"$prefix"} fi fi +if [ "$TOKENS_PROVIDER" == "erc20_erc721" ]; then + prefix='contract address: ' + output=$($CLI deploy $STACK_NAME ../data/erc20/ERC20WithData.json | grep address) + export ERC20_CONTRACT_ADDRESS=${output#"$prefix"} + prefix='contract address: ' + output=$($CLI deploy $STACK_NAME ../data/erc721/ERC721WithData.json | grep address) + export ERC721_CONTRACT_ADDRESS=${output#"$prefix"} +fi + $CLI info $STACK_NAME checkOk $? diff --git a/test/e2e/stack.go b/test/e2e/stack.go index dfac7b25e..d3004be39 100644 --- a/test/e2e/stack.go +++ b/test/e2e/stack.go @@ -25,6 +25,7 @@ type Stack struct { Name string `json:"name,omitempty"` ExposedBlockchainPort int `json:"exposedGethPort,omitempty"` BlockchainProvider string `json:"blockchainProvider"` + TokenProviders []string `json:"tokenProviders"` Members []*Member `json:"members,omitempty"` } diff --git a/test/e2e/tokens_test.go b/test/e2e/tokens_test.go index 4b5be2ffd..5f1c59c6b 100644 --- a/test/e2e/tokens_test.go +++ b/test/e2e/tokens_test.go @@ -18,6 +18,7 @@ package e2e import ( "fmt" + "os" "time" "github.com/hyperledger/firefly/pkg/fftypes" @@ -27,7 +28,28 @@ import ( type TokensTestSuite struct { suite.Suite - testState *testState + testState *testState + connector string + erc20Address string + erc721Address string +} + +func (suite *TokensTestSuite) SetupSuite() { + suite.testState = beforeE2ETest(suite.T()) + stack := readStackFile(suite.T()) + suite.connector = stack.TokenProviders[0] + if suite.connector == "erc20_erc721" { + suite.erc20Address = os.Getenv("ERC20_CONTRACT_ADDRESS") + if suite.erc20Address == "" { + suite.T().Fatal("ERC20_CONTRACT_ADDRESS must be set") + } + suite.T().Logf("ERC20 address: %s", suite.erc20Address) + suite.erc721Address = os.Getenv("ERC721_CONTRACT_ADDRESS") + if suite.erc20Address == "" { + suite.T().Fatal("ERC721_CONTRACT_ADDRESS must be set") + } + suite.T().Logf("ERC721 address: %s", suite.erc721Address) + } } func (suite *TokensTestSuite) BeforeTest(suiteName, testName string) { @@ -45,9 +67,14 @@ func (suite *TokensTestSuite) TestE2EFungibleTokensAsync() { suite.T().Logf("Pool name: %s", poolName) pool := &fftypes.TokenPool{ - Name: poolName, - Type: fftypes.TokenTypeFungible, + Name: poolName, + Type: fftypes.TokenTypeFungible, + Config: fftypes.JSONObject{}, } + if suite.erc20Address != "" { + pool.Config["address"] = suite.erc20Address + } + poolResp := CreateTokenPool(suite.T(), suite.testState.client1, pool, false) poolID := poolResp.ID @@ -55,7 +82,7 @@ func (suite *TokensTestSuite) TestE2EFungibleTokensAsync() { pools = GetTokenPools(suite.T(), suite.testState.client1, suite.testState.startTime) assert.Equal(suite.T(), 1, len(pools)) assert.Equal(suite.T(), "default", pools[0].Namespace) - assert.Equal(suite.T(), "erc1155", pools[0].Connector) + assert.Equal(suite.T(), suite.connector, pools[0].Connector) assert.Equal(suite.T(), poolName, pools[0].Name) assert.Equal(suite.T(), fftypes.TokenTypeFungible, pools[0].Type) assert.NotEmpty(suite.T(), pools[0].ProtocolID) @@ -64,7 +91,7 @@ func (suite *TokensTestSuite) TestE2EFungibleTokensAsync() { pools = GetTokenPools(suite.T(), suite.testState.client1, suite.testState.startTime) assert.Equal(suite.T(), 1, len(pools)) assert.Equal(suite.T(), "default", pools[0].Namespace) - assert.Equal(suite.T(), "erc1155", pools[0].Connector) + assert.Equal(suite.T(), suite.connector, pools[0].Connector) assert.Equal(suite.T(), poolName, pools[0].Name) assert.Equal(suite.T(), fftypes.TokenTypeFungible, pools[0].Type) assert.NotEmpty(suite.T(), pools[0].ProtocolID) @@ -82,7 +109,7 @@ func (suite *TokensTestSuite) TestE2EFungibleTokensAsync() { waitForEvent(suite.T(), received1, fftypes.EventTypeApprovalConfirmed, approvalOut.LocalID) approvals := GetTokenApprovals(suite.T(), suite.testState.client1, poolID) assert.Equal(suite.T(), 1, len(approvals)) - assert.Equal(suite.T(), "erc1155", approvals[0].Connector) + assert.Equal(suite.T(), suite.connector, approvals[0].Connector) assert.Equal(suite.T(), true, approvals[0].Approved) transfer := &fftypes.TokenTransferInput{ @@ -94,7 +121,7 @@ func (suite *TokensTestSuite) TestE2EFungibleTokensAsync() { waitForEvent(suite.T(), received1, fftypes.EventTypeTransferConfirmed, transferOut.LocalID) transfers := GetTokenTransfers(suite.T(), suite.testState.client1, poolID) assert.Equal(suite.T(), 1, len(transfers)) - assert.Equal(suite.T(), "erc1155", transfers[0].Connector) + assert.Equal(suite.T(), suite.connector, transfers[0].Connector) assert.Equal(suite.T(), fftypes.TokenTransferTypeMint, transfers[0].Type) assert.Equal(suite.T(), int64(1), transfers[0].Amount.Int().Int64()) validateAccountBalances(suite.T(), suite.testState.client1, poolID, "", map[string]int64{ @@ -104,7 +131,7 @@ func (suite *TokensTestSuite) TestE2EFungibleTokensAsync() { waitForEvent(suite.T(), received2, fftypes.EventTypeTransferConfirmed, nil) transfers = GetTokenTransfers(suite.T(), suite.testState.client2, poolID) assert.Equal(suite.T(), 1, len(transfers)) - assert.Equal(suite.T(), "erc1155", transfers[0].Connector) + assert.Equal(suite.T(), suite.connector, transfers[0].Connector) assert.Equal(suite.T(), fftypes.TokenTransferTypeMint, transfers[0].Type) assert.Equal(suite.T(), int64(1), transfers[0].Amount.Int().Int64()) validateAccountBalances(suite.T(), suite.testState.client2, poolID, "", map[string]int64{ @@ -132,7 +159,7 @@ func (suite *TokensTestSuite) TestE2EFungibleTokensAsync() { waitForEvent(suite.T(), received1, fftypes.EventTypeMessageConfirmed, transferOut.Message) transfers = GetTokenTransfers(suite.T(), suite.testState.client1, poolID) assert.Equal(suite.T(), 2, len(transfers)) - assert.Equal(suite.T(), "erc1155", transfers[0].Connector) + assert.Equal(suite.T(), suite.connector, transfers[0].Connector) assert.Equal(suite.T(), fftypes.TokenTransferTypeTransfer, transfers[0].Type) assert.Equal(suite.T(), int64(1), transfers[0].Amount.Int().Int64()) data := GetDataForMessage(suite.T(), suite.testState.client1, suite.testState.startTime, transfers[0].Message) @@ -146,7 +173,7 @@ func (suite *TokensTestSuite) TestE2EFungibleTokensAsync() { waitForEvent(suite.T(), received2, fftypes.EventTypeMessageConfirmed, transferOut.Message) transfers = GetTokenTransfers(suite.T(), suite.testState.client2, poolID) assert.Equal(suite.T(), 2, len(transfers)) - assert.Equal(suite.T(), "erc1155", transfers[0].Connector) + assert.Equal(suite.T(), suite.connector, transfers[0].Connector) assert.Equal(suite.T(), fftypes.TokenTransferTypeTransfer, transfers[0].Type) assert.Equal(suite.T(), int64(1), transfers[0].Amount.Int().Int64()) validateAccountBalances(suite.T(), suite.testState.client2, poolID, "", map[string]int64{ @@ -163,7 +190,7 @@ func (suite *TokensTestSuite) TestE2EFungibleTokensAsync() { waitForEvent(suite.T(), received2, fftypes.EventTypeTransferConfirmed, transferOut.LocalID) transfers = GetTokenTransfers(suite.T(), suite.testState.client2, poolID) assert.Equal(suite.T(), 3, len(transfers)) - assert.Equal(suite.T(), "erc1155", transfers[0].Connector) + assert.Equal(suite.T(), suite.connector, transfers[0].Connector) assert.Equal(suite.T(), fftypes.TokenTransferTypeBurn, transfers[0].Type) assert.Equal(suite.T(), "", transfers[0].TokenIndex) assert.Equal(suite.T(), int64(1), transfers[0].Amount.Int().Int64()) @@ -175,7 +202,7 @@ func (suite *TokensTestSuite) TestE2EFungibleTokensAsync() { waitForEvent(suite.T(), received1, fftypes.EventTypeTransferConfirmed, nil) transfers = GetTokenTransfers(suite.T(), suite.testState.client1, poolID) assert.Equal(suite.T(), 3, len(transfers)) - assert.Equal(suite.T(), "erc1155", transfers[0].Connector) + assert.Equal(suite.T(), suite.connector, transfers[0].Connector) assert.Equal(suite.T(), fftypes.TokenTransferTypeBurn, transfers[0].Type) assert.Equal(suite.T(), "", transfers[0].TokenIndex) assert.Equal(suite.T(), int64(1), transfers[0].Amount.Int().Int64()) @@ -210,9 +237,14 @@ func (suite *TokensTestSuite) TestE2ENonFungibleTokensSync() { suite.T().Logf("Pool name: %s", poolName) pool := &fftypes.TokenPool{ - Name: poolName, - Type: fftypes.TokenTypeNonFungible, + Name: poolName, + Type: fftypes.TokenTypeNonFungible, + Config: fftypes.JSONObject{}, } + if suite.erc721Address != "" { + pool.Config["address"] = suite.erc721Address + } + poolOut := CreateTokenPool(suite.T(), suite.testState.client1, pool, true) assert.Equal(suite.T(), "default", poolOut.Namespace) assert.Equal(suite.T(), poolName, poolOut.Name) @@ -243,12 +275,15 @@ func (suite *TokensTestSuite) TestE2ENonFungibleTokensSync() { waitForEvent(suite.T(), received1, fftypes.EventTypeApprovalConfirmed, approvalOut.LocalID) approvals := GetTokenApprovals(suite.T(), suite.testState.client1, poolID) assert.Equal(suite.T(), 1, len(approvals)) - assert.Equal(suite.T(), "erc1155", approvals[0].Connector) + assert.Equal(suite.T(), suite.connector, approvals[0].Connector) assert.Equal(suite.T(), true, approvals[0].Approved) transfer := &fftypes.TokenTransferInput{ - TokenTransfer: fftypes.TokenTransfer{Amount: *fftypes.NewFFBigInt(1)}, - Pool: poolName, + TokenTransfer: fftypes.TokenTransfer{ + TokenIndex: "1", + Amount: *fftypes.NewFFBigInt(1), + }, + Pool: poolName, } transferOut := MintTokens(suite.T(), suite.testState.client1, transfer, true) assert.Equal(suite.T(), fftypes.TokenTransferTypeMint, transferOut.Type) From 509b7330b564467ea35bc9cd3cf247c1b4100f80 Mon Sep 17 00:00:00 2001 From: Andrew Richardson Date: Thu, 17 Mar 2022 23:35:32 -0400 Subject: [PATCH 3/5] Store token pool info Signed-off-by: Andrew Richardson --- db/migrations/postgres/000072_add_tokenpool_info.down.sql | 3 +++ db/migrations/postgres/000072_add_tokenpool_info.up.sql | 3 +++ db/migrations/sqlite/000072_add_tokenpool_info.down.sql | 1 + db/migrations/sqlite/000072_add_tokenpool_info.up.sql | 1 + internal/database/sqlcommon/tokenpool_sql.go | 4 ++++ internal/database/sqlcommon/tokenpool_sql_test.go | 3 +++ 6 files changed, 15 insertions(+) create mode 100644 db/migrations/postgres/000072_add_tokenpool_info.down.sql create mode 100644 db/migrations/postgres/000072_add_tokenpool_info.up.sql create mode 100644 db/migrations/sqlite/000072_add_tokenpool_info.down.sql create mode 100644 db/migrations/sqlite/000072_add_tokenpool_info.up.sql diff --git a/db/migrations/postgres/000072_add_tokenpool_info.down.sql b/db/migrations/postgres/000072_add_tokenpool_info.down.sql new file mode 100644 index 000000000..f810b6bcb --- /dev/null +++ b/db/migrations/postgres/000072_add_tokenpool_info.down.sql @@ -0,0 +1,3 @@ +BEGIN; +ALTER TABLE tokenpool DROP COLUMN info; +COMMIT; diff --git a/db/migrations/postgres/000072_add_tokenpool_info.up.sql b/db/migrations/postgres/000072_add_tokenpool_info.up.sql new file mode 100644 index 000000000..e4c3396da --- /dev/null +++ b/db/migrations/postgres/000072_add_tokenpool_info.up.sql @@ -0,0 +1,3 @@ +BEGIN; +ALTER TABLE tokenpool ADD COLUMN info TEXT; +COMMIT; diff --git a/db/migrations/sqlite/000072_add_tokenpool_info.down.sql b/db/migrations/sqlite/000072_add_tokenpool_info.down.sql new file mode 100644 index 000000000..ce0590e77 --- /dev/null +++ b/db/migrations/sqlite/000072_add_tokenpool_info.down.sql @@ -0,0 +1 @@ +ALTER TABLE tokenpool DROP COLUMN info; diff --git a/db/migrations/sqlite/000072_add_tokenpool_info.up.sql b/db/migrations/sqlite/000072_add_tokenpool_info.up.sql new file mode 100644 index 000000000..d40f2bceb --- /dev/null +++ b/db/migrations/sqlite/000072_add_tokenpool_info.up.sql @@ -0,0 +1 @@ +ALTER TABLE tokenpool ADD COLUMN info TEXT; diff --git a/internal/database/sqlcommon/tokenpool_sql.go b/internal/database/sqlcommon/tokenpool_sql.go index f1b3ff913..1e239e2bf 100644 --- a/internal/database/sqlcommon/tokenpool_sql.go +++ b/internal/database/sqlcommon/tokenpool_sql.go @@ -42,6 +42,7 @@ var ( "created", "tx_type", "tx_id", + "info", } tokenPoolFilterFieldMap = map[string]string{ "protocolid": "protocol_id", @@ -93,6 +94,7 @@ func (s *SQLCommon) UpsertTokenPool(ctx context.Context, pool *fftypes.TokenPool Set("state", pool.State). Set("tx_type", pool.TX.Type). Set("tx_id", pool.TX.ID). + Set("info", pool.Info). Where(sq.Eq{"id": pool.ID}), func() { s.callbacks.UUIDCollectionNSEvent(database.CollectionTokenPools, fftypes.ChangeEventTypeUpdated, pool.Namespace, pool.ID) @@ -119,6 +121,7 @@ func (s *SQLCommon) UpsertTokenPool(ctx context.Context, pool *fftypes.TokenPool pool.Created, pool.TX.Type, pool.TX.ID, + pool.Info, ), func() { s.callbacks.UUIDCollectionNSEvent(database.CollectionTokenPools, fftypes.ChangeEventTypeCreated, pool.Namespace, pool.ID) @@ -147,6 +150,7 @@ func (s *SQLCommon) tokenPoolResult(ctx context.Context, row *sql.Rows) (*fftype &pool.Created, &pool.TX.Type, &pool.TX.ID, + &pool.Info, ) if err != nil { return nil, i18n.WrapError(ctx, err, i18n.MsgDBReadErr, "tokenpool") diff --git a/internal/database/sqlcommon/tokenpool_sql_test.go b/internal/database/sqlcommon/tokenpool_sql_test.go index 39644a4b6..fd1c6612e 100644 --- a/internal/database/sqlcommon/tokenpool_sql_test.go +++ b/internal/database/sqlcommon/tokenpool_sql_test.go @@ -52,6 +52,9 @@ func TestTokenPoolE2EWithDB(t *testing.T) { Type: fftypes.TransactionTypeTokenPool, ID: fftypes.NewUUID(), }, + Info: fftypes.JSONObject{ + "pool": "info", + }, } s.callbacks.On("UUIDCollectionNSEvent", database.CollectionTokenPools, fftypes.ChangeEventTypeCreated, "ns1", poolID, mock.Anything). From c632456ca25a1eac950df33efa5382121a0d365c Mon Sep 17 00:00:00 2001 From: Andrew Richardson Date: Fri, 18 Mar 2022 10:56:14 -0400 Subject: [PATCH 4/5] Update manifest for firefly-tokens-erc20-erc721 Signed-off-by: Andrew Richardson --- manifest.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/manifest.json b/manifest.json index 775fe36ed..d38f1ffce 100644 --- a/manifest.json +++ b/manifest.json @@ -21,8 +21,8 @@ }, "tokens-erc20-erc721": { "image": "ghcr.io/hyperledger/firefly-tokens-erc20-erc721", - "tag": "v0.1.6", - "sha": "142dcd72355a73c2ba69f3c1eeab8a7ab5c304a7e01ee19f14a8a95d20b4262d" + "tag": "v0.1.6-20220318-20", + "sha": "8330f526e499c0dbeae036d7df3af601b33628ddbf570f3fb731599a32c7f0a3" }, "build": { "firefly-builder": { From f90e90afeff44fe374875cb5c5a4e92b515189c2 Mon Sep 17 00:00:00 2001 From: Andrew Richardson Date: Fri, 18 Mar 2022 10:58:47 -0400 Subject: [PATCH 5/5] Remove fabric+erc1155 from E2E matrix Signed-off-by: Andrew Richardson --- .github/workflows/go.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/go.yml b/.github/workflows/go.yml index 39ce7dcdd..9956812bf 100644 --- a/.github/workflows/go.yml +++ b/.github/workflows/go.yml @@ -39,6 +39,8 @@ jobs: test-suite: TestFabricE2ESuite - blockchain-provider: fabric test-suite: TestEthereumE2ESuite + - blockchain-provider: fabric + token-provider: erc1155 - blockchain-provider: fabric token-provider: erc20_erc721 - blockchain-provider: geth