Skip to content

Commit

Permalink
Translate emitter addresses from Aptos
Browse files Browse the repository at this point in the history
  • Loading branch information
Agustin Godnic committed Jun 28, 2023
1 parent 36e5a59 commit 53b3716
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
11 changes: 11 additions & 0 deletions common/domain/chainid.go
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,13 @@ func TranslateEmitterAddress(chainID sdk.ChainID, address string) (string, error
return "", fmt.Errorf(`no mapping found for Sui emitter address "%s"`, address)
}

case sdk.ChainIDAptos:
if nativeAddress, ok := aptosMappings[address]; ok {
return nativeAddress, nil
} else {
return "", fmt.Errorf(`no mapping found for Aptos emitter address "%s"`, address)
}

default:
return "", fmt.Errorf("can't translate emitter address: ChainID=%d not supported", chainID)
}
Expand All @@ -180,3 +187,7 @@ var nearMappings = map[string]string{
var suiMappings = map[string]string{
"ccceeb29348f71bdd22ffef43a2a19c1f5b5e17c5cca5411529120182672ade5": "0xc57508ee0d4595e5a8728974a4a93a787d38f339757230d441e895422c07aba9",
}

var aptosMappings = map[string]string{
"0000000000000000000000000000000000000000000000000000000000000001": "0x576410486a2da45eee6c949c995670112ddf2fbeedab20350d506328eefc9d4f",
}
6 changes: 6 additions & 0 deletions common/domain/chainid_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,12 @@ func TestTranslateEmitterAddress(t *testing.T) {
emitterAddress: "ccceeb29348f71bdd22ffef43a2a19c1f5b5e17c5cca5411529120182672ade5",
want: "0xc57508ee0d4595e5a8728974a4a93a787d38f339757230d441e895422c07aba9",
},
{
// Aptos - Token Bridge emitter
emitterChain: sdk.ChainIDAptos,
emitterAddress: "0000000000000000000000000000000000000000000000000000000000000001",
want: "0x576410486a2da45eee6c949c995670112ddf2fbeedab20350d506328eefc9d4f",
},
}

// For each test case
Expand Down

0 comments on commit 53b3716

Please sign in to comment.