New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

ether-pudding

Package Overview
Dependencies
Maintainers
1
Versions
43
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ether-pudding - npm Package Compare versions

Comparing version 0.0.5 to 0.0.6

216

build/ether-pudding.js

@@ -11,7 +11,12 @@ (function() {

Pudding.whisk = function(abi, class_defaults) {
Pudding.whisk = function(abi, code, class_defaults) {
var contract;
if (typeof code === "object") {
class_defaults = code;
code = null;
}
contract = web3.eth.contract(abi);
contract = Pudding.inject_defaults(contract, class_defaults);
contract = Pudding.synchronize_contract(contract);
contract = Pudding.make_nicer_new(contract, code);
if (Promise != null) {

@@ -35,7 +40,47 @@ contract = Pudding.promisify_contract(contract);

Pudding.merge = function() {
var i, key, len, merged, object, value;
merged = {};
for (i = 0, len = arguments.length; i < len; i++) {
object = arguments[i];
for (key in object) {
value = object[key];
merged[key] = value;
}
}
return merged;
};
Pudding.inject_defaults = function(contract_class, class_defaults) {
var old_at;
var inject, old_at, old_new;
old_at = contract_class.at;
old_new = contract_class["new"];
inject = (function(_this) {
return function(instance, instance_defaults) {
var abi_object, fn, fn_name, i, key, len, merged_defaults, ref, value;
if (instance_defaults == null) {
instance_defaults = {};
}
merged_defaults = _this.merge(class_defaults, instance_defaults);
ref = contract_class.abi;
for (i = 0, len = ref.length; i < len; i++) {
abi_object = ref[i];
fn_name = abi_object.name;
fn = instance[fn_name];
if (fn == null) {
continue;
}
instance[fn_name] = Pudding.inject_defaults_into_function(instance, fn, merged_defaults);
for (key in fn) {
value = fn[key];
instance[fn_name][key] = value;
}
instance[fn_name].sendTransaction = Pudding.inject_defaults_into_function(instance, fn.sendTransaction, merged_defaults);
instance[fn_name].call = Pudding.inject_defaults_into_function(instance, fn.call, merged_defaults);
}
return instance;
};
})(this);
contract_class.at = function(address, instance_defaults) {
var abi_object, fn, fn_name, i, instance, key, len, merged_defaults, ref, value;
var instance;
if (instance_defaults == null) {

@@ -45,29 +90,31 @@ instance_defaults = {};

instance = old_at.call(contract_class, address);
merged_defaults = {};
for (key in class_defaults) {
value = class_defaults[key];
merged_defaults[key] = value;
}
for (key in instance_defaults) {
value = instance_defaults[key];
merged_defaults[key] = value;
}
ref = contract_class.abi;
for (i = 0, len = ref.length; i < len; i++) {
abi_object = ref[i];
fn_name = abi_object.name;
fn = instance[fn_name];
if (fn == null) {
continue;
return inject(instance, instance_defaults);
};
contract_class["new"] = (function(_this) {
return function() {
var args, callback, instance_defaults, tx_params;
args = Array.prototype.slice.call(arguments);
callback = args.pop();
if (typeof args[args.length - 1] === "object" && typeof args[args.length - 2] === "object") {
instance_defaults = args.pop();
tx_params = args.pop();
} else {
instance_defaults = {};
if (args[args.length - 1] === "object") {
tx_params = args.pop();
} else {
tx_params = {};
}
}
instance[fn_name] = Pudding.inject_defaults_into_function(instance, fn, merged_defaults);
for (key in fn) {
value = fn[key];
instance[fn_name][key] = value;
}
instance[fn_name].sendTransaction = Pudding.inject_defaults_into_function(instance, fn.sendTransaction, merged_defaults);
instance[fn_name].call = Pudding.inject_defaults_into_function(instance, fn.call, merged_defaults);
}
return instance;
};
tx_params = _this.merge(Pudding.global_defaults, class_defaults, tx_params);
args.push(tx_params, function(err, instance) {
if (err != null) {
callback(err);
return;
}
return callback(null, inject(instance));
});
return old_new.apply(contract_class, args);
};
})(this);
return contract_class;

@@ -79,21 +126,9 @@ };

return function() {
var args, callback, key, old_options, options, ref, value;
var args, callback, old_options, options;
args = Array.prototype.slice.call(arguments);
callback = args.pop();
options = {};
ref = Pudding.global_defaults;
for (key in ref) {
value = ref[key];
options[key] = value;
}
for (key in merged_defaults) {
value = merged_defaults[key];
options[key] = value;
}
options = _this.merge(Pudding.global_defaults, merged_defaults);
if (typeof args[args.length - 1] === "object") {
old_options = args.pop();
for (key in old_options) {
value = old_options[key];
options[key] = value;
}
options = _this.merge(options, old_options);
}

@@ -107,10 +142,7 @@ args.push(options, callback);

Pudding.promisify_contract = function(contract_class) {
var old_at;
var old_at, old_new, promisify;
old_at = contract_class.at;
contract_class.at = function(address, instance_defaults) {
var fn, instance, k, key, v;
if (instance_defaults == null) {
instance_defaults = {};
}
instance = old_at.call(contract_class, address, instance_defaults);
old_new = contract_class["new"];
promisify = function(instance) {
var fn, k, key, v;
for (key in instance) {

@@ -132,5 +164,55 @@ fn = instance[key];

};
contract_class.at = function(address, instance_defaults) {
var instance;
if (instance_defaults == null) {
instance_defaults = {};
}
instance = old_at.call(contract_class, address, instance_defaults);
return promisify(instance);
};
contract_class["new"] = Promise.promisify(function() {
var args, callback;
args = Array.prototype.slice.call(arguments);
callback = args.pop();
args.push(function(err, instance) {
if (err != null) {
callback(err);
}
return callback(null, promisify(instance));
});
return old_new.apply(contract_class, args);
});
return contract_class;
};
Pudding.make_nicer_new = function(contract_class, code) {
var old_new;
if (code == null) {
code = "";
}
old_new = contract_class["new"];
contract_class["new"] = function() {
var args, callback, instance_defaults, tx_params;
args = Array.prototype.slice.call(arguments);
callback = args.pop();
if (typeof args[args.length - 1] === "object" && typeof args[args.length - 2] === "object") {
instance_defaults = args.pop();
tx_params = args.pop();
} else {
instance_defaults = {};
if (args[args.length - 1] === "object") {
tx_params = args.pop();
} else {
tx_params = {};
}
}
if (tx_params.data == null) {
tx_params.data = code;
}
args.push(tx_params, instance_defaults, callback);
return old_new.apply(contract_class, args);
};
return contract_class;
};
Pudding.synchronize_function = function(instance, fn) {

@@ -178,10 +260,7 @@ var attempts, interval, max_attempts;

Pudding.synchronize_contract = function(contract_class) {
var old_at;
var old_at, old_new, synchronize;
old_at = contract_class.at;
contract_class.at = function(address, instance_defaults) {
var abi_object, fn, fn_name, i, instance, key, len, ref, value;
if (instance_defaults == null) {
instance_defaults = {};
}
instance = old_at.call(contract_class, address, instance_defaults);
old_new = contract_class["new"];
synchronize = function(instance) {
var abi_object, fn, fn_name, i, key, len, ref, value;
ref = contract_class.abi;

@@ -203,2 +282,23 @@ for (i = 0, len = ref.length; i < len; i++) {

};
contract_class.at = function(address, instance_defaults) {
var instance;
if (instance_defaults == null) {
instance_defaults = {};
}
instance = old_at.call(contract_class, address, instance_defaults);
return synchronize(instance);
};
contract_class["new"] = function() {
var args, callback, instance;
args = Array.prototype.slice.call(arguments);
callback = args.pop();
args.push(function(err, instance) {
if (err != null) {
callback(err);
return;
}
return callback(null, synchronize(instance));
});
return instance = old_new.apply(contract_class, arguments);
};
return contract_class;

@@ -205,0 +305,0 @@ };

@@ -1,2 +0,2 @@

/*! ether-pudding 30-06-2015 */
(function(){var a;a=function(a,b){var c;return c=function(){function c(){}return c.global_defaults={},c.whisk=function(d,e){var f;return f=b.eth.contract(d),f=c.inject_defaults(f,e),f=c.synchronize_contract(f),null!=a&&(f=c.promisify_contract(f)),f},c.defaults=function(a){var b,d;null==a&&(a={});for(b in a)d=a[b],c.global_defaults[b]=d;return c.global_defaults},c.inject_defaults=function(a,b){var d;return d=a.at,a.at=function(e,f){var g,h,i,j,k,l,m,n,o,p;null==f&&(f={}),k=d.call(a,e),n={};for(l in b)p=b[l],n[l]=p;for(l in f)p=f[l],n[l]=p;for(o=a.abi,j=0,m=o.length;m>j;j++)if(g=o[j],i=g.name,h=k[i],null!=h){k[i]=c.inject_defaults_into_function(k,h,n);for(l in h)p=h[l],k[i][l]=p;k[i].sendTransaction=c.inject_defaults_into_function(k,h.sendTransaction,n),k[i].call=c.inject_defaults_into_function(k,h.call,n)}return k},a},c.inject_defaults_into_function=function(a,b,d){return function(e){return function(){var e,f,g,h,i,j,k;e=Array.prototype.slice.call(arguments),f=e.pop(),i={},j=c.global_defaults;for(g in j)k=j[g],i[g]=k;for(g in d)k=d[g],i[g]=k;if("object"==typeof e[e.length-1]){h=e.pop();for(g in h)k=h[g],i[g]=k}return e.push(i,f),b.apply(a,e)}}(this)},c.promisify_contract=function(b){var c;return c=b.at,b.at=function(d,e){var f,g,h,i,j;null==e&&(e={}),g=c.call(b,d,e);for(i in g)if(f=g[i],"object"==typeof f||"function"==typeof f){for(h in f)j=f[h],("object"==typeof f||"function"==typeof f)&&(f[h]=a.promisify(j,g));g[i]=a.promisify(f,g)}return g},b},c.synchronize_function=function(a,c){var d,e,f;return e=null,f=240,d=0,function(){var g,h,i;return g=Array.prototype.slice.call(arguments),h=g.pop(),i=function(a,c){var g,i;return null!=a?void h(a,c):(i=c,e=null,g=function(){return b.eth.getTransaction(i,function(a,b){return null==a?(null!=b.blockHash&&(clearInterval(e),h(null,i)),d>=f&&(clearInterval(e),h("Transaction "+i+" wasn't processed in "+d+" attempts!",i)),d+=1):void 0})},e=setInterval(g,1e3),g())},g.push(i),c.apply(a,g)}},c.synchronize_contract=function(a){var b;return b=a.at,a.at=function(d,e){var f,g,h,i,j,k,l,m,n;for(null==e&&(e={}),j=b.call(a,d,e),m=a.abi,i=0,l=m.length;l>i;i++)if(f=m[i],h=f.name,g=j[h],null!=g){j[h]=c.synchronize_function(j,g);for(k in g)n=g[k],j[h][k]=n}return j},a},c}()},"undefined"!=typeof module&&null!==module&&null!=module.exports?module.exports=a(require("bluebird"),require("web3")):window.Pudding=a(Promise,web3)}).call(this);
/*! ether-pudding 08-07-2015 */
(function(){var a;a=function(a,b){var c;return c=function(){function c(){}return c.global_defaults={},c.whisk=function(d,e,f){var g;return"object"==typeof e&&(f=e,e=null),g=b.eth.contract(d),g=c.inject_defaults(g,f),g=c.synchronize_contract(g),g=c.make_nicer_new(g,e),null!=a&&(g=c.promisify_contract(g)),g},c.defaults=function(a){var b,d;null==a&&(a={});for(b in a)d=a[b],c.global_defaults[b]=d;return c.global_defaults},c.merge=function(){var a,b,c,d,e,f;for(d={},a=0,c=arguments.length;c>a;a++){e=arguments[a];for(b in e)f=e[b],d[b]=f}return d},c.inject_defaults=function(a,b){var d,e,f;return e=a.at,f=a["new"],d=function(d){return function(e,f){var g,h,i,j,k,l,m,n,o;for(null==f&&(f={}),m=d.merge(b,f),n=a.abi,j=0,l=n.length;l>j;j++)if(g=n[j],i=g.name,h=e[i],null!=h){e[i]=c.inject_defaults_into_function(e,h,m);for(k in h)o=h[k],e[i][k]=o;e[i].sendTransaction=c.inject_defaults_into_function(e,h.sendTransaction,m),e[i].call=c.inject_defaults_into_function(e,h.call,m)}return e}}(this),a.at=function(b,c){var f;return null==c&&(c={}),f=e.call(a,b),d(f,c)},a["new"]=function(e){return function(){var g,h,i,j;return g=Array.prototype.slice.call(arguments),h=g.pop(),"object"==typeof g[g.length-1]&&"object"==typeof g[g.length-2]?(i=g.pop(),j=g.pop()):(i={},j="object"===g[g.length-1]?g.pop():{}),j=e.merge(c.global_defaults,b,j),g.push(j,function(a,b){return null!=a?void h(a):h(null,d(b))}),f.apply(a,g)}}(this),a},c.inject_defaults_into_function=function(a,b,d){return function(e){return function(){var f,g,h,i;return f=Array.prototype.slice.call(arguments),g=f.pop(),i=e.merge(c.global_defaults,d),"object"==typeof f[f.length-1]&&(h=f.pop(),i=e.merge(i,h)),f.push(i,g),b.apply(a,f)}}(this)},c.promisify_contract=function(b){var c,d,e;return c=b.at,d=b["new"],e=function(b){var c,d,e,f;for(e in b)if(c=b[e],"object"==typeof c||"function"==typeof c){for(d in c)f=c[d],("object"==typeof c||"function"==typeof c)&&(c[d]=a.promisify(f,b));b[e]=a.promisify(c,b)}return b},b.at=function(a,d){var f;return null==d&&(d={}),f=c.call(b,a,d),e(f)},b["new"]=a.promisify(function(){var a,c;return a=Array.prototype.slice.call(arguments),c=a.pop(),a.push(function(a,b){return null!=a&&c(a),c(null,e(b))}),d.apply(b,a)}),b},c.make_nicer_new=function(a,b){var c;return null==b&&(b=""),c=a["new"],a["new"]=function(){var d,e,f,g;return d=Array.prototype.slice.call(arguments),e=d.pop(),"object"==typeof d[d.length-1]&&"object"==typeof d[d.length-2]?(f=d.pop(),g=d.pop()):(f={},g="object"===d[d.length-1]?d.pop():{}),null==g.data&&(g.data=b),d.push(g,f,e),c.apply(a,d)},a},c.synchronize_function=function(a,c){var d,e,f;return e=null,f=240,d=0,function(){var g,h,i;return g=Array.prototype.slice.call(arguments),h=g.pop(),i=function(a,c){var g,i;return null!=a?void h(a,c):(i=c,e=null,g=function(){return b.eth.getTransaction(i,function(a,b){return null==a?(null!=b.blockHash&&(clearInterval(e),h(null,i)),d>=f&&(clearInterval(e),h("Transaction "+i+" wasn't processed in "+d+" attempts!",i)),d+=1):void 0})},e=setInterval(g,1e3),g())},g.push(i),c.apply(a,g)}},c.synchronize_contract=function(a){var b,d,e;return b=a.at,d=a["new"],e=function(b){var d,e,f,g,h,i,j,k;for(j=a.abi,g=0,i=j.length;i>g;g++)if(d=j[g],f=d.name,e=b[f],null!=e){b[f]=c.synchronize_function(b,e);for(h in e)k=e[h],b[f][h]=k}return b},a.at=function(c,d){var f;return null==d&&(d={}),f=b.call(a,c,d),e(f)},a["new"]=function(){var b,c,f;return b=Array.prototype.slice.call(arguments),c=b.pop(),b.push(function(a,b){return null!=a?void c(a):c(null,e(b))}),f=d.apply(a,arguments)},a},c}()},"undefined"!=typeof module&&null!==module&&null!=module.exports?module.exports=a(require("bluebird"),require("web3")):window.Pudding=a(Promise,web3)}).call(this);
{
"name": "ether-pudding",
"version": "0.0.5",
"version": "0.0.6",
"description": "Pudding - a (more) delightful Ethereum contract abstraction",

@@ -21,5 +21,6 @@ "author": "Tim Coulter",

"grunt-contrib-coffee": "*",
"grunt-contrib-uglify": "*"
"grunt-contrib-uglify": "*",
"grunt-contrib-watch": "*"
},
"license": "MIT License. Copyright Consensys LLC, and authors. All rights reserved."
}

@@ -40,3 +40,5 @@ # The Proof is in the Pudding

MyContract = Pudding.whisk(abi) # You need to provide abi
# You need to provide your contract's abi and binary code.
# You can get these by compiling your contracts with solidity compiler, solc.
MyContract = Pudding.whisk(abi, binary)
```

@@ -85,2 +87,14 @@

Because you provided your contract's binary code in `Pudding.whisk()`, you can create new contracts that get added to the network really easily:
```
MetaCoin.new().then (coin) ->
# From here, the example becomes just like the above.
# Note that coin.address is the addres of the newly created contract.
coin.sendCoin(...)
.catch (err) ->
console.log "Error creating contract!"
console.log err.stack
```
### More Examples

@@ -87,0 +101,0 @@

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc