| 
 | 1 | +import { describe, expect, it } from 'vitest'  | 
 | 2 | +import { getInstantiate2Address } from '../module-factory'  | 
 | 3 | +import {  | 
 | 4 | +  generateSha512Salt,  | 
 | 5 | +  predictPolytoneProxyAddress,  | 
 | 6 | +} from './predict-proxy-address'  | 
 | 7 | + | 
 | 8 | +describe('predictPolytoneProxyAddress', () => {  | 
 | 9 | +  // https://github.com/DA0-DA0/polytone/blob/f70440a35f12f97a9018849ca7e6d241a53582ce/cw-orch-state.json  | 
 | 10 | +  const neutronNoteAddress =  | 
 | 11 | +    'neutron1767kfqeglqyctuqsmvyzgjecs60lpqju2f590smxevk9duq5fhaqgk5eca'  | 
 | 12 | +  const neutronToOsmosisVoiceAddress =  | 
 | 13 | +    'osmo1vw02frqejfw2v2w7dy6ws35jp9743dwkxy0laalwsuvzzvkszz7s8d93yw'  | 
 | 14 | +  // https://celatone.osmosis.zone/osmosis-1/codes/127  | 
 | 15 | +  const osmosisProxyChecksum =  | 
 | 16 | +    '5094551145BCD256538775A0611CE9E88F8D7A182A06F082F901FFED9184BB5A'  | 
 | 17 | +  // The sender from the source chain  | 
 | 18 | +  const neutronSenderAddress =  | 
 | 19 | +    'neutron13vzaav9pdsnuccy9wjzauv205q4e70t8lwtvngsqhyqs3xdjlu0sglylyv'  | 
 | 20 | +  // From state of Voice contract  | 
 | 21 | +  const connectionIdFromVoice = 'connection-2338'  | 
 | 22 | +  // https://celatone.osmosis.zone/osmosis-1/contracts/osmo1fgdp4k54nmhuydwmgfzygm0fjyvaz0thz8rglctpl5lehe57tcyqqfy698  | 
 | 23 | +  const expectedAddress =  | 
 | 24 | +    'osmo1fgdp4k54nmhuydwmgfzygm0fjyvaz0thz8rglctpl5lehe57tcyqqfy698'  | 
 | 25 | + | 
 | 26 | +  it('returns the correct address with raw functions', async () => {  | 
 | 27 | +    const salt = generateSha512Salt(  | 
 | 28 | +      connectionIdFromVoice,  | 
 | 29 | +      `wasm.${neutronNoteAddress}`,  | 
 | 30 | +      neutronSenderAddress,  | 
 | 31 | +    )  | 
 | 32 | + | 
 | 33 | +    const result = await getInstantiate2Address(  | 
 | 34 | +      neutronToOsmosisVoiceAddress,  | 
 | 35 | +      osmosisProxyChecksum,  | 
 | 36 | +      salt,  | 
 | 37 | +    )  | 
 | 38 | + | 
 | 39 | +    // https://celatone.osmosis.zone/osmosis-1/contracts/osmo1fgdp4k54nmhuydwmgfzygm0fjyvaz0thz8rglctpl5lehe57tcyqqfy698  | 
 | 40 | +    expect(result).toBe(expectedAddress)  | 
 | 41 | +  })  | 
 | 42 | + | 
 | 43 | +  it('returns the correct address with full function', async () => {  | 
 | 44 | +    const result = await predictPolytoneProxyAddress({  | 
 | 45 | +      hostVoiceAddress: neutronToOsmosisVoiceAddress,  | 
 | 46 | +      hostProxyChecksum: osmosisProxyChecksum,  | 
 | 47 | +      hostVoiceConnectionId: connectionIdFromVoice,  | 
 | 48 | +      controllerNoteAddress: neutronNoteAddress,  | 
 | 49 | +      controllerSender: neutronSenderAddress,  | 
 | 50 | +    })  | 
 | 51 | + | 
 | 52 | +    expect(result).toBe(expectedAddress)  | 
 | 53 | +  })  | 
 | 54 | +})  | 
0 commit comments