onflow / freshmint

Apache License 2.0
68 stars 17 forks source link

Use constant royalties, set on contract deployment #138

Closed psiemens closed 2 years ago

psiemens commented 2 years ago

This PR updates the royalties field to a constant field that is initialized on contract deployment.

If using royalties, they must be set on contract deployment. However, you can omit the royalties field to deploy a contract with no royalties.

Please see the updated documentation: https://github.com/packagelabs/freshmint/blob/static-royalties/docs/nodejs.md#2-deploy-your-contract-with-royalties-recipients

Note: this introduces a breaking change to the contract.deploy function. Parameters are now passed as an object rather than as positional arguments.

@RenanSgorlom I can reverse this if it's difficult for you to change, but IMO it does make it easier to pass in optional arguments like royalties.

// Old way (deprecated)
contract.deploy(publicKey, hashAlgorithm, placeholderImage, { saveAdminResourceToContractAccount: true });

// New way
contract.deploy({ 
  publicKey,
  hashAlgorithm,
  placeholderImage,
  saveAdminResourceToContractAccount: true,
  // royalties field is optional 
  royalties: [...]
});