Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pointers contracts: support for ERC1155 and CW1155 contracts #1755

Merged
merged 113 commits into from
Dec 5, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
113 commits
Select commit Hold shift + click to select a range
9eab721
wip cw1155 pointer
dirtyshab May 24, 2024
33d8bfd
cleanup todos
dirtyshab Jun 5, 2024
0061483
sync events with current standard
dirtyshab Jun 5, 2024
9f0d299
fix query BalanceOfBatch
dirtyshab Jun 5, 2024
45c654f
fix import
dirtyshab Jun 5, 2024
0269627
Fix up cwerc1155 compiled files
dvli2007 Jun 15, 2024
4d706dd
Add 1155 requests into bindings
dvli2007 Jun 20, 2024
533bca6
queries
mr-meat Jun 20, 2024
792da46
follow same coding style
mr-meat Jun 20, 2024
6304c6d
Add cwerc1155.wasm binary to `/contracts`
dvli2007 Jun 21, 2024
68df425
Add go code to support new pointer contract
dvli2007 Jun 21, 2024
3502209
Fix typo
dvli2007 Jun 21, 2024
cca521c
Add updated protobuf files
dvli2007 Jun 21, 2024
f7fa05d
Fix up tests
dvli2007 Jun 21, 2024
2e6622e
Merge pull request #5 from palletexchange/add-new-pointer
dvli2007 Jun 21, 2024
aa22642
Merge branch 'main' into cw1155
dvli2007 Jun 21, 2024
ae6a095
Deprecate pointer proposals
dvli2007 Jun 21, 2024
5082b6b
queries
mr-meat Jun 20, 2024
cb2ba41
follow same coding style
mr-meat Jun 20, 2024
d260408
safetransfer functions, royalyinfo, set approval
mr-meat Jun 25, 2024
1e2ca09
add in exe queries and royaltyinfo
mr-meat Jun 25, 2024
39978bb
Merge branch 'main' into cw1155
dvli2007 Jun 25, 2024
a05cbac
Merge branch 'cw1155' into davy/cw1155
dvli2007 Jun 25, 2024
1ee0e92
adding in transfer and approval tests
mr-meat Jun 25, 2024
1d91ef5
solc and abigen
mr-meat Jun 26, 2024
b117fb2
clean up unused artifacts
mr-meat Jun 26, 2024
8b818a0
Merge pull request #6 from palletexchange/erc1155
dvli2007 Jun 27, 2024
ed38c98
Merge branch 'cw1155' into davy/cw1155
dvli2007 Jun 27, 2024
68ed5a0
Add all go bindings
dvli2007 Jun 30, 2024
3989fc3
Merge pull request #7 from palletexchange/davy/cw1155
dvli2007 Jun 30, 2024
2cce20c
return unsupported for methods not supported in erc standard
dirtyshab Jul 1, 2024
7b0668e
Merge pull request #9 from palletexchange/cw1155
scottirvine Jul 1, 2024
f5858a8
fix query BalanceOfBatch response
dirtyshab Jul 1, 2024
5d0750c
Add new test files
dvli2007 Jul 1, 2024
a00687b
fix Erc1155BalanceOfBatchResponse
dirtyshab Jul 2, 2024
18768c1
More testing
dvli2007 Jul 2, 2024
b2b9a6c
Merge pull request #8 from palletexchange/cw1155-cleanup
dvli2007 Jul 2, 2024
ae52356
Merge pull request #10 from palletexchange/davy/test-cw1155
dvli2007 Jul 2, 2024
327d5fd
Update cwerc1155.wasm
dvli2007 Jul 2, 2024
6736609
More tests
dvli2007 Jul 3, 2024
95fc243
return true/false instead of erroring in query IsApprovedForAll
dirtyshab Jul 3, 2024
219a3ca
use correct response for query BalanceOfBatch
dirtyshab Jul 3, 2024
134252a
pass optional token id field to evm query TotalSupply
dirtyshab Jul 3, 2024
0c429e9
remove todos
dirtyshab Jul 3, 2024
f2b67b3
remove AllTokenInfo query
dirtyshab Jul 3, 2024
bcfc760
Fix balances query struct
dvli2007 Jul 3, 2024
eaa110d
Update and rebuild CW1155 pointer
dvli2007 Jul 3, 2024
d9b54b3
Add new cw1155 wasms
dvli2007 Jul 3, 2024
4ae3e4b
Merge pull request #12 from palletexchange/cw1155
scottirvine Jul 3, 2024
d91e3cb
merge
mr-meat Jul 3, 2024
846f7c2
Update cwerc1155.wasm
dvli2007 Jul 3, 2024
61e2c27
Fix up ERC1155 pointer tests
dvli2007 Jul 3, 2024
2c537ed
balanceOfBatch
mr-meat Jul 3, 2024
2c0c498
adding in expect calls
mr-meat Jul 3, 2024
7c8bc90
remove unused import
mr-meat Jul 3, 2024
60cbbce
Round of updates to cw1155 contracts
dvli2007 Jul 3, 2024
487ac30
Update cw1155 pointer tests
dvli2007 Jul 3, 2024
8c1e7a4
Fix: missing ERC1155TransferPayload
dvli2007 Jul 3, 2024
0d7a6cb
removing unnecessary return
mr-meat Jul 3, 2024
8949624
Update binary
dvli2007 Jul 3, 2024
b964fd0
Merge branch 'erc1155' into cw1155-localtest
dvli2007 Jul 3, 2024
db6af24
Fix balance of batch
dvli2007 Jul 3, 2024
b3ac9de
Merge branch 'erc1155' into cw1155-localtest
dvli2007 Jul 3, 2024
bcb3b3c
Merge pull request #14 from palletexchange/cw1155-localtest
dvli2007 Jul 3, 2024
a5a1c51
Merge branch 'main' into cw1155
dvli2007 Jul 4, 2024
e372e13
add minor checks
dvli2007 Jul 4, 2024
f129599
Update integration test with latest main updates
dvli2007 Jul 4, 2024
adc2519
Fix up erc721-payload and erc1155-payload cli commands
dvli2007 Jul 4, 2024
2e2d938
Merge branch 'main' into pointers/erc1155-cw1155
dvli2007 Jul 9, 2024
7541497
Lint code
dvli2007 Jul 12, 2024
a73a8a1
Merge branch 'main' into pointers/erc1155-cw1155
dvli2007 Jul 12, 2024
4f6aa54
Merge branch 'pointers/erc1155-cw1155' of github.com:palletexchange/s…
dvli2007 Jul 12, 2024
d39f380
Update integration test with new pointer contract code id
dvli2007 Jul 12, 2024
532a24d
Merge branch 'main' into pointers/erc1155-cw1155
dvli2007 Jul 22, 2024
0fdfbe5
Map CW1155 events to EVM
dvli2007 Jul 23, 2024
86d0dd3
updates from cw1155 base
dirtyshab Jul 23, 2024
1caea56
update cw1155 base
dirtyshab Jul 24, 2024
fd8ef0f
Test events emissions for cw1155 events
dvli2007 Jul 24, 2024
649e610
Update wasm build for cwerc1155
dvli2007 Jul 24, 2024
4229eeb
Merge branch 'update-base-cw1155' into pointers/erc1155-cw1155
dvli2007 Jul 24, 2024
66bc71c
Fix integration test 1
dvli2007 Jul 24, 2024
6478b68
update cw1155 cargo, add optimize script to cargo
dirtyshab Jul 25, 2024
89b349b
Merge branch 'update-base-cw1155' into pointers/erc1155-cw1155
dvli2007 Jul 25, 2024
21f7765
Update wasm builds
dvli2007 Jul 25, 2024
01322e9
Merge branch 'main' into pointers/erc1155-cw1155
dvli2007 Jul 25, 2024
dbdcbc0
Add migrations for 1155s
dvli2007 Jul 25, 2024
2c0db74
Code quality
dvli2007 Jul 25, 2024
b9389cb
Merge branch 'main' into pointers/erc1155-cw1155
dvli2007 Jul 25, 2024
c004c54
Remove unnecessary lines
dvli2007 Jul 26, 2024
e9ffdc3
Merge branch 'main' into pointers/erc1155-cw1155
dvli2007 Jul 26, 2024
9e53e07
updates from audit on cw1155 standard
dirtyshab Oct 14, 2024
28a803e
[P1-I-01] Validate parameters in the "balanceOfBatch" function
dvli2007 Oct 16, 2024
bd6825d
build pointer wasm from audit changes
dirtyshab Oct 16, 2024
5707da9
update pointer wasms in other places
dirtyshab Oct 16, 2024
3593569
[P1-H-01] Fix "safeBatchTransferFrom" - change to "onERC1155BatchRece…
dvli2007 Oct 16, 2024
b1b963d
[P1-I-02] Consider adding "ERC1155Burnable" to "CW1155ERC1155Pointer"
dvli2007 Oct 16, 2024
11c38df
Fix CW1155ERC1155Pointer.sol styles
dvli2007 Oct 16, 2024
253f3de
Update ERC1155 pointer artifacts
dvli2007 Oct 16, 2024
6aa1613
Merge pull request #20 from palletexchange/erc1155-audit
dvli2007 Oct 16, 2024
304f47f
send funds if empty msg in send and send_batch
dirtyshab Oct 22, 2024
728be34
Merge pull request #18 from palletexchange/sec3-audit
dvli2007 Nov 20, 2024
800b40f
Merge branch 'main' into pointers/erc1155-cw1155
dvli2007 Nov 20, 2024
26e5f38
Merge branch 'main' into pointers/erc1155-cw1155
dvli2007 Nov 21, 2024
cf69463
Merge branch 'main' into pointers/erc1155-cw1155
dvli2007 Nov 21, 2024
55ec5d7
rebuild cw1155 pointer/standard
dirtyshab Nov 21, 2024
28d679f
fix version issue
dirtyshab Nov 21, 2024
77c841f
cw1155_base wasm fix
dirtyshab Nov 22, 2024
1d839d0
Update and fix tests
dvli2007 Nov 22, 2024
038f177
Fix tests
dvli2007 Nov 22, 2024
89c1367
Remove events from 1155 pointer so as not to double-emit
dvli2007 Nov 22, 2024
3e057bf
Linting
dvli2007 Nov 22, 2024
91c36bd
Merge branch 'main' into pointers/erc1155-cw1155
dvli2007 Nov 22, 2024
f8498b8
Merge branch 'main' into pointers/erc1155-cw1155
dvli2007 Dec 3, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Merge branch 'main' into pointers/erc1155-cw1155
  • Loading branch information
dvli2007 committed Nov 21, 2024
commit 26e5f38c811162e84749bf81fa86eca56cfe9b59
22 changes: 1 addition & 21 deletions app/receipt.go
Original file line number Diff line number Diff line change
Expand Up @@ -195,12 +195,7 @@ func (app *App) translateCW721Event(ctx sdk.Context, wasmEvent abci.Event, point
}
var topics []common.Hash
switch action {
case "transfer_nft", "send_nft":
topics = []common.Hash{
ERC721TransferTopic,
app.GetEvmAddressAttribute(ctx, wasmEvent, "sender"),
app.GetEvmAddressAttribute(ctx, wasmEvent, "recipient"),
}
case "transfer_nft", "send_nft", "burn":
tokenID := GetTokenIDAttribute(wasmEvent)
if tokenID == nil {
return nil, false
Expand Down Expand Up @@ -242,21 +237,6 @@ func (app *App) translateCW721Event(ctx sdk.Context, wasmEvent abci.Event, point
Topics: topics,
Data: EmptyHash.Bytes(),
}, true
case "burn":
topics = []common.Hash{
ERC721TransferTopic,
app.GetEvmAddressAttribute(ctx, wasmEvent, "sender"),
EmptyHash,
}
tokenID := GetTokenIDAttribute(wasmEvent)
if tokenID == nil {
return nil, false
}
return &ethtypes.Log{
Address: pointerAddr,
Topics: topics,
Data: common.BigToHash(tokenID).Bytes(),
}, true
case "mint":
tokenID := GetTokenIDAttribute(wasmEvent)
if tokenID == nil {
Expand Down
10 changes: 6 additions & 4 deletions precompiles/common/expected_keepers.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,11 +60,13 @@ type EVMKeeper interface {
ctx sdk.Context, evm *vm.EVM, cw20Addr string, metadata utils.ERCMetadata,
) (contractAddr common.Address, err error)
UpsertERCCW721Pointer(
ctx sdk.Context, evm *vm.EVM, suppliedGas uint64, cw721Addr string, metadata utils.ERCMetadata,
) (contractAddr common.Address, remainingGas uint64, err error)
ctx sdk.Context, evm *vm.EVM, cw721Addr string, metadata utils.ERCMetadata,
) (contractAddr common.Address, err error)
UpsertERCCW1155Pointer(
ctx sdk.Context, evm *vm.EVM, suppliedGas uint64, cw1155Addr string, metadata utils.ERCMetadata,
) (contractAddr common.Address, remainingGas uint64, err error)
ctx sdk.Context, evm *vm.EVM, cw1155Addr string, metadata utils.ERCMetadata,
) (contractAddr common.Address, err error)
GetEVMGasLimitFromCtx(ctx sdk.Context) uint64
GetCosmosGasLimitFromEVMGas(ctx sdk.Context, evmGas uint64) uint64
}

type AccountKeeper interface {
Expand Down
12 changes: 7 additions & 5 deletions precompiles/pointer/pointer.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,9 +81,9 @@ func (p PrecompileExecutor) Execute(ctx sdk.Context, method *ethabi.Method, call
case AddCW20Pointer:
return p.AddCW20(ctx, method, caller, args, value, evm)
case AddCW721Pointer:
return p.AddCW721(ctx, method, caller, args, value, evm, suppliedGas)
return p.AddCW721(ctx, method, caller, args, value, evm)
case AddCW1155Pointer:
return p.AddCW1155(ctx, method, caller, args, value, evm, suppliedGas)
return p.AddCW1155(ctx, method, caller, args, value, evm)
default:
err = fmt.Errorf("unknown method %s", method.Name)
}
Expand Down Expand Up @@ -190,7 +190,7 @@ func (p PrecompileExecutor) AddCW721(ctx sdk.Context, method *ethabi.Method, cal
return
}

func (p PrecompileExecutor) AddCW1155(ctx sdk.Context, method *ethabi.Method, caller common.Address, args []interface{}, value *big.Int, evm *vm.EVM, suppliedGas uint64) (ret []byte, remainingGas uint64, err error) {
func (p PrecompileExecutor) AddCW1155(ctx sdk.Context, method *ethabi.Method, caller common.Address, args []interface{}, value *big.Int, evm *vm.EVM) (ret []byte, remainingGas uint64, err error) {
if err := pcommon.ValidateNonPayable(value); err != nil {
return nil, 0, err
}
Expand All @@ -202,7 +202,7 @@ func (p PrecompileExecutor) AddCW1155(ctx sdk.Context, method *ethabi.Method, ca
if err != nil {
return nil, 0, err
}
res, err := p.wasmdKeeper.QuerySmart(ctx, cwAddress, []byte("{\"contract_info\":{}}"))
res, err := p.wasmdKeeper.QuerySmartSafe(ctx, cwAddress, []byte("{\"contract_info\":{}}"))
if err != nil {
return nil, 0, err
}
Expand All @@ -212,10 +212,12 @@ func (p PrecompileExecutor) AddCW1155(ctx sdk.Context, method *ethabi.Method, ca
}
name := formattedRes["name"].(string)
symbol := formattedRes["symbol"].(string)
contractAddr, remainingGas, err := p.evmKeeper.UpsertERCCW1155Pointer(ctx, evm, suppliedGas, cwAddr, utils.ERCMetadata{Name: name, Symbol: symbol})
contractAddr, err := p.evmKeeper.UpsertERCCW1155Pointer(ctx, evm, cwAddr, utils.ERCMetadata{Name: name, Symbol: symbol})
if err != nil {
return nil, 0, err
}
ret, err = method.Outputs.Pack(contractAddr)
remainingGas = pcommon.GetRemainingGas(ctx, p.evmKeeper)
return
}

1 change: 0 additions & 1 deletion x/evm/integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -608,4 +608,3 @@ func signTx(txBuilder client.TxBuilder, privKey cryptotypes.PrivKey, acc authtyp
_ = txBuilder.SetSignatures(sigsV2...)
return txBuilder.GetTx()
}

6 changes: 3 additions & 3 deletions x/evm/keeper/pointer_upgrade.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,10 +74,10 @@ func (k *Keeper) UpsertERCCW721Pointer(
}

func (k *Keeper) UpsertERCCW1155Pointer(
ctx sdk.Context, evm *vm.EVM, suppliedGas uint64, cw1155Addr string, metadata utils.ERCMetadata,
) (contractAddr common.Address, remainingGas uint64, err error) {
ctx sdk.Context, evm *vm.EVM, cw1155Addr string, metadata utils.ERCMetadata,
) (contractAddr common.Address, err error) {
return k.UpsertERCPointer(
ctx, evm, suppliedGas, "cw1155", []interface{}{
ctx, evm, "cw721", []interface{}{
cw1155Addr, metadata.Name, metadata.Symbol,
}, k.GetERC1155CW1155Pointer, k.SetERC1155CW1155Pointer,
)
Expand Down
8 changes: 5 additions & 3 deletions x/evm/keeper/pointer_upgrade_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -123,10 +123,12 @@ func TestUpsertERC721Pointer(t *testing.T) {
}

func TestUpsertERC1155Pointer(t *testing.T) {
k, ctx := testkeeper.MockEVMKeeper()
k := &testkeeper.EVMTestApp.EvmKeeper
ctx := testkeeper.EVMTestApp.GetContextForDeliverTx([]byte{}).WithBlockTime(time.Now())
ctx = ctx.WithGasMeter(sdk.NewInfiniteGasMeterWithMultiplier(ctx))
var addr common.Address
err := k.RunWithOneOffEVMInstance(ctx, func(e *vm.EVM) error {
a, _, err := k.UpsertERCCW1155Pointer(ctx, e, math.MaxUint64, "test", utils.ERCMetadata{
a, err := k.UpsertERCCW1155Pointer(ctx, e, "test", utils.ERCMetadata{
Name: "test",
Symbol: "test",
})
Expand All @@ -136,7 +138,7 @@ func TestUpsertERC1155Pointer(t *testing.T) {
require.Nil(t, err)
var newAddr common.Address
err = k.RunWithOneOffEVMInstance(ctx, func(e *vm.EVM) error {
a, _, err := k.UpsertERCCW1155Pointer(ctx, e, math.MaxUint64, "test", utils.ERCMetadata{
a, err := k.UpsertERCCW1155Pointer(ctx, e, "test", utils.ERCMetadata{
Name: "test2",
Symbol: "test2",
})
Expand Down
2 changes: 1 addition & 1 deletion x/evm/migrations/migrate_all_pointers.go
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ func MigrateERCCW1155Pointers(ctx sdk.Context, k *keeper.Keeper) error {
continue
}
_ = k.RunWithOneOffEVMInstance(ctx, func(e *vm.EVM) error {
_, _, err := k.UpsertERCCW1155Pointer(ctx, e, math.MaxUint64, cwAddr, utils.ERCMetadata{
_, err := k.UpsertERCCW1155Pointer(ctx.WithGasMeter(sdk.NewInfiniteGasMeterWithMultiplier(ctx)), e, cwAddr, utils.ERCMetadata{
Name: oName.(string),
Symbol: oSymbol.(string),
})
Expand Down
2 changes: 1 addition & 1 deletion x/evm/migrations/migrate_all_pointers_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ func TestMigrateERCCW1155Pointers(t *testing.T) {
ctx := testkeeper.EVMTestApp.GetContextForDeliverTx([]byte{}).WithBlockTime(time.Now())
var pointerAddr common.Address
require.Nil(t, k.RunWithOneOffEVMInstance(ctx, func(e *vm.EVM) error {
a, _, err := k.UpsertERCCW1155Pointer(ctx, e, math.MaxUint64, "test", utils.ERCMetadata{Name: "name", Symbol: "symbol"})
a, err := k.UpsertERCCW1155Pointer(ctx, e, "test", utils.ERCMetadata{Name: "name", Symbol: "symbol"})
pointerAddr = a
return err
}, func(s1, s2 string) {}))
Expand Down
12 changes: 12 additions & 0 deletions x/evm/module.go
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,18 @@ func (am AppModule) RegisterServices(cfg module.Configurator) {
})

_ = cfg.RegisterMigration(types.ModuleName, 11, func(ctx sdk.Context) error {
return migrations.MigrateDeliverTxHookWasmGasLimitParam(ctx, am.keeper)
})

_ = cfg.RegisterMigration(types.ModuleName, 12, func(ctx sdk.Context) error {
return migrations.MigrateBlockBloom(ctx, am.keeper)
})

_ = cfg.RegisterMigration(types.ModuleName, 13, func(ctx sdk.Context) error {
return migrations.MigrateEip1559Params(ctx, am.keeper)
})

_ = cfg.RegisterMigration(types.ModuleName, 14, func(ctx sdk.Context) error {
return migrations.StoreCWPointerCode(ctx, am.keeper, false, false, true)
})
}
Expand Down
You are viewing a condensed version of this merge commit. You can view the full changes here.