ethpm / ethpm-spec

Ethereum Package Manager http://ethpm.github.io/ethpm-spec/
165 stars 30 forks source link

Externally changeable configuration variables for contracts #55

Closed axic closed 6 years ago

axic commented 7 years ago

For example the following contract uses an external variable:

contract A {
  function tokenName() returns (string) {
     return globals("TOKEN_NAME");
  }
}

That variable could be defined in the package configuration in a form similar to this:

globals: {
  "name": {
    type: "string",
    value: "testToken"
  },
  "version": {
    type: "uint256",
    value: 42
  },
  "registryAddress": {
    type: "address",
    value: 0x42...
  }
}

Would that make any sense for ethpm?

For more details see: https://github.com/ethereum/solidity/issues/1650

tcoulter commented 7 years ago

Wouldn't this be a function of deployment? Couldn't the contract just as easily take that value in as a constructor parameter? This would be my preference as it wouldn't require preprocessing or any other tricks.

On Feb 5, 2017 2:22 PM, "Alex Beregszaszi" notifications@github.com wrote:

For example the following contract uses an external variable:

contract A { function tokenName() returns (string) { return globals("TOKEN_NAME"); } }

That variable could be defined in the package configuration. Would that make any sense for ethpm?

For more details see: ethereum/solidity#1650 https://github.com/ethereum/solidity/issues/1650

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/ethpm/ethpm-spec/issues/55, or mute the thread https://github.com/notifications/unsubscribe-auth/AAFp1ZZoK8qpWcT-WcCUF1p65Km7V6K5ks5rZkuRgaJpZM4L3pn9 .

axic commented 7 years ago

@tcoulter there is no preprocessing needed, it is a compiler feature, it is only about passing these variables in a given format to the compiler. See the linked issue.

tcoulter commented 7 years ago

I thought you were going to say that. :) i was not aware of that. Sorry, was on my phone.

Spec would need to be updated, but sounds reasonable.

On Feb 5, 2017 2:26 PM, "Alex Beregszaszi" notifications@github.com wrote:

@tcoulter https://github.com/tcoulter there is no preprocessing needed, it is a compiler feature, it is only about passing these variables in a given format to the compiler. See the linked issue.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/ethpm/ethpm-spec/issues/55#issuecomment-277555107, or mute the thread https://github.com/notifications/unsubscribe-auth/AAFp1WhyqXw3vmJJ_54Wu_gW6XDK3owLks5rZkywgaJpZM4L3pn9 .

pipermerriam commented 7 years ago

Axic, can you link me to anywhere that I can read more about this? Not a computer feature I'm currently aware of.

On Sun, Feb 5, 2017, 3:28 PM Tim Coulter notifications@github.com wrote:

I thought you were going to say that. :) i was not aware of that. Sorry, was on my phone.

Spec would need to be updated, but sounds reasonable.

On Feb 5, 2017 2:26 PM, "Alex Beregszaszi" notifications@github.com wrote:

@tcoulter https://github.com/tcoulter there is no preprocessing needed, it is a compiler feature, it is only about passing these variables in a given format to the compiler. See the linked issue.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/ethpm/ethpm-spec/issues/55#issuecomment-277555107, or mute the thread < https://github.com/notifications/unsubscribe-auth/AAFp1WhyqXw3vmJJ_54Wu_gW6XDK3owLks5rZkywgaJpZM4L3pn9

.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/ethpm/ethpm-spec/issues/55#issuecomment-277555195, or mute the thread https://github.com/notifications/unsubscribe-auth/AAyTgtXMQXrepWWgLMUgO3mxzrbJgPDYks5rZk0HgaJpZM4L3pn9 .

axic commented 7 years ago

For more details see: ethereum/solidity#1650

The link on the top ^^ 😉

pipermerriam commented 7 years ago

My apologies. Also on mobile.

On Sun, Feb 5, 2017, 3:32 PM Alex Beregszaszi notifications@github.com wrote:

For more details see: ethereum/solidity#1650 https://github.com/ethereum/solidity/issues/1650

The link on the top ^^ 😉

— You are receiving this because you commented.

Reply to this email directly, view it on GitHub https://github.com/ethpm/ethpm-spec/issues/55#issuecomment-277555496, or mute the thread https://github.com/notifications/unsubscribe-auth/AAyTgr_ywYHHgclkvo-Nj0lDYB4hqjCQks5rZk3tgaJpZM4L3pn9 .

axic commented 7 years ago

All of you sitting at the Superbowl and texting? :)

pipermerriam commented 7 years ago

Building Lego cities with my 3 year old.

Yes this totally fits in the spec. Probably in an update to the compiler setting section.

On Sun, Feb 5, 2017, 3:34 PM Alex Beregszaszi notifications@github.com wrote:

All of you sitting at the Superbowl and texting? :)

— You are receiving this because you commented.

Reply to this email directly, view it on GitHub https://github.com/ethpm/ethpm-spec/issues/55#issuecomment-277555613, or mute the thread https://github.com/notifications/unsubscribe-auth/AAyTgu0qv0NOc-kiVPjDETf1ExL5hrWjks5rZk5agaJpZM4L3pn9 .

VoR0220 commented 7 years ago

Hmmm...when i am less inebriated i will have to reread this. Because currently its not making full sense to me.

axic commented 7 years ago

Copied the sample configuration from Solidity to this issue. Probably clearer this way.

nmushegian commented 7 years ago

between this and erc190 I don't feel insane anymore! yay!

https://github.com/ethereum/solidity/issues/242

nmushegian commented 7 years ago

I <3 ethpm so much

pipermerriam commented 7 years ago

:P So I'm thinking that this is getting a general 👍 and makes sense as the first element for what we can call either the v1.1 version of the spec or v2 depending on what versioning scheme we'd like to use. I think I'm preferential to v2

tcoulter commented 7 years ago

I'm also preferential to whole number version increments.

Also :+1: for this feature.

On Feb 5, 2017 3:51 PM, "Piper Merriam" notifications@github.com wrote:

:P So I'm thinking that this is getting a general 👍 and makes sense as the first element for what we can call either the v1.1 version of the spec or v2 depending on what versioning scheme we'd like to use. I think I'm preferential to v2

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/ethpm/ethpm-spec/issues/55#issuecomment-277560568, or mute the thread https://github.com/notifications/unsubscribe-auth/AAFp1b476xemvbxcJN-epZO1jxL6Z4Tnks5rZmBzgaJpZM4L3pn9 .

gnidan commented 6 years ago

(closing, won't fix)

Contract source is already used as an opaque blob of text, and there exists a property for compiler settings. Instead, compiler settings should be expanded to be more lenient (see #81); this would enable this use case.