Skip to content

Commit

Permalink
Merge pull request #98 from arkprotocol/class_id_fix
Browse files Browse the repository at this point in the history
receive callback fix: query NFT contract from storage (and not instantiate2)
  • Loading branch information
shanev authored Jun 20, 2024
2 parents 1f39e18 + 811f567 commit 8e8de23
Show file tree
Hide file tree
Showing 33 changed files with 1,359 additions and 1,037 deletions.
2 changes: 1 addition & 1 deletion contracts/ics721-base/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ pub fn execute(
}

#[cfg_attr(not(feature = "library"), entry_point)]
pub fn query(deps: Deps, env: Env, msg: QueryMsg) -> StdResult<Binary> {
pub fn query(deps: Deps, env: Env, msg: QueryMsg) -> Result<Binary, ContractError> {
Ics721Contract::default().query(deps, env, msg)
}

Expand Down
2 changes: 1 addition & 1 deletion contracts/sg-ics721/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ pub fn execute(
}

#[cfg_attr(not(feature = "library"), entry_point)]
pub fn query(deps: Deps, env: Env, msg: QueryMsg) -> StdResult<Binary> {
pub fn query(deps: Deps, env: Env, msg: QueryMsg) -> Result<Binary, ContractError> {
SgIcs721Contract::default().query(deps, env, msg)
}

Expand Down
2 changes: 1 addition & 1 deletion contracts/sg-ics721/src/testing/integration_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ fn execute(
SgIcs721Contract::default().execute(deps, env, info, msg)
}

fn query(deps: Deps, env: Env, msg: QueryMsg) -> StdResult<Binary> {
fn query(deps: Deps, env: Env, msg: QueryMsg) -> Result<Binary, ContractError> {
SgIcs721Contract::default().query(deps, env, msg)
}

Expand Down
241 changes: 121 additions & 120 deletions e2e/adversarial_test.go

Large diffs are not rendered by default.

60 changes: 60 additions & 0 deletions e2e/basic_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
package e2e

import (
"encoding/json"
"testing"

wasmibctesting "github.com/CosmWasm/wasmd/x/wasm/ibctesting"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/public-awesome/ics721/e2e/test_suite"
"github.com/stretchr/testify/require"
"github.com/stretchr/testify/suite"
)

type BasicTestSuite struct {
suite.Suite

coordinator *wasmibctesting.Coordinator

// testing chains used for convenience and readability
chainA *wasmibctesting.TestChain

chainABridge sdk.AccAddress
}

func TestBasic(t *testing.T) {
suite.Run(t, new(BasicTestSuite))
}

func (suite *BasicTestSuite) SetupTest() {
suite.coordinator = wasmibctesting.NewCoordinator(suite.T(), 2)
suite.chainA = suite.coordinator.GetChain(wasmibctesting.GetChainID(0))
}

func (suite *BasicTestSuite) TestStoreCodes() {
// Store the ICS721 contract.
chainAStoreResp := suite.chainA.StoreCodeFile("../artifacts/ics721_base.wasm")
require.Equal(suite.T(), uint64(1), chainAStoreResp.CodeID)

// Store the cw721 contract.
chainAStoreResp = suite.chainA.StoreCodeFile("../external-wasms/cw721_base_v0.18.0.wasm")
require.Equal(suite.T(), uint64(2), chainAStoreResp.CodeID)
}

func (suite *BasicTestSuite) TestInstantiateIcs721() {
// Store the ICS721 contract.
chainAStoreResp := suite.chainA.StoreCodeFile("../artifacts/ics721_base.wasm")
require.Equal(suite.T(), uint64(1), chainAStoreResp.CodeID)

// Instantiate the ICS721 contract.
instantiateICS721 := test_suite.InstantiateICS721Bridge{
Cw721BaseCodeId: 1,
// no pauser nor proxy by default.
OutgoingProxy: nil,
IncomingProxy: nil,
Pauser: nil,
}
instantiateICS721Raw, err := json.Marshal(instantiateICS721)
require.NoError(suite.T(), err)
suite.chainABridge = suite.chainA.InstantiateContract(1, instantiateICS721Raw)
}
Loading

0 comments on commit 8e8de23

Please sign in to comment.