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

replaceImportAddresses doesn't replace all instances (multiple imports / inline instances) #73

Closed
march213 opened this issue Jun 8, 2022 · 3 comments
Assignees
Labels
bug Something isn't working

Comments

@march213
Copy link

march213 commented Jun 8, 2022

Problem

👋🏻 Hey!

We have a cadence file where we have:

  • multiple imports: import FirstContract, SecondContract from 0xContract
  • inline instances:
      pre {
          self.account.address == AddressThatNeedsToBeReplaced: "Invalid"
      }

Steps to Reproduce

Multiple imports example:

const addressMap = {
  Messages: '0xf8d6e0586b0a20c7',
  OtherMessages: '0xf8d6e0586b0a20c7',
};

const code = `
  import Messages, OtherMessages from 0x1
  
  pub fun main(){}
`;

const replaced = replaceImportAddresses(code, addressMap);
console.log({ replaced });

Inline instances example

const addressMap = {
  Messages: '0xf8d6e0586b0a20c7',
  OtherMessages: '0xf8d6e0586b0a20c7',
};

const code2 = `
import Messages from 0x1

transaction() {
    pre {
        self.address == Messages: "Failed" // inlined here
    }
}
`;

const replaced2 = replaceImportAddresses(code2, addressMap);
console.log({ replaced2 });

Acceptance Criteria

Would be nice if the replaceImportAddresses method would replace multiple imports and inline instances.

Is supporting this in on your roadmap ?

@march213 march213 added the bug Something isn't working label Jun 8, 2022
@MaxStalker
Copy link
Contributor

Hey, @march213 👋

  • Multiple imports should be easy to fix. Thank you for flagging this 👍
  • Inline instances is a bit more tricky, unless it's something easy to tag and replace for example if it comes with # prefix - i.e #MESSAGES 🤔

@march213
Copy link
Author

march213 commented Jun 8, 2022

Multiple imports should be easy to fix. Thank you for flagging this 👍

That's awesome!

Inline instances is a bit more tricky, unless it's something easy to tag and replace for example if it comes with # prefix - i.e #MESSAGES

That potentially could work.

@jribbink
Copy link
Contributor

This has been triaged into two separate issues: #117 #118

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants