Skip to content
This repository has been archived by the owner on Mar 7, 2023. It is now read-only.

Commit

Permalink
feat(Contacts): expose uuid function for iOS to override
Browse files Browse the repository at this point in the history
  • Loading branch information
kwgithubusername committed Aug 2, 2017
1 parent 8a9a1a9 commit e0d4ecf
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
4 changes: 1 addition & 3 deletions src/contact.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ const Metadata = require('./metadata');
const assoc = require('ramda/src/assoc');
const prop = require('ramda/src/prop');
const map = require('ramda/src/map');
const uuid = require('uuid');
const FacilitatedTx = require('./facilitatedTx');

class Contact {
Expand All @@ -29,8 +28,7 @@ Contact.factory = function (o) {
return new Contact(o);
};

Contact.new = function (o) {
const id = uuid();
Contact.new = function (o, id) {
const namedContact = assoc('id', id, o);
return new Contact(namedContact);
};
Expand Down
12 changes: 8 additions & 4 deletions src/contacts.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,15 @@ Contacts.prototype.wipe = function () {
};

Contacts.prototype.new = function (object) {
const c = Contact.new(object);
const c = Contact.new(object, this.uuid());
this.list = R.assoc(c.id, c, this.list);
return c;
};

Contacts.prototype.uuid = function() {
return uuid();
}

const fromNull = (str) => str || '';
const isContact = (uniqueId) => R.where({id: R.equals(uniqueId)});
const contains = R.curry((substr, key) => R.where(R.objOf(key, R.compose(R.contains(substr), fromNull))));
Expand Down Expand Up @@ -217,7 +221,7 @@ const cancelResponse = function (id) {
// I want you to pay me
Contacts.prototype.sendPR = function (userId, intendedAmount, id, note, initiatorSource) {
// we should reserve the address (check buy-sell) - should probable be an argument
id = id ? id : uuid()
id = id ? id : this.uuid()
const contact = this.get(userId);
const account = initiatorSource != null ? MyWallet.wallet.hdwallet.accounts[initiatorSource] : MyWallet.wallet.hdwallet.defaultAccount;
const address = account.receiveAddress;
Expand All @@ -235,7 +239,7 @@ Contacts.prototype.sendPR = function (userId, intendedAmount, id, note, initiato

// request payment request (step-1)
Contacts.prototype.sendRPR = function (userId, intendedAmount, id, note) {
id = id ? id : uuid()
id = id ? id : this.uuid()
const message = requestPaymentRequest(intendedAmount, id, note);
const contact = this.get(userId);
return this.sendMessage(userId, REQUEST_PAYMENT_REQUEST_TYPE, message)
Expand All @@ -245,7 +249,7 @@ Contacts.prototype.sendRPR = function (userId, intendedAmount, id, note) {

// payment request response
Contacts.prototype.sendPRR = function (userId, txHash, id) {
id = id ? id : uuid()
id = id ? id : this.uuid()
const message = paymentRequestResponse(id, txHash);
const contact = this.get(userId);
return this.sendMessage(userId, PAYMENT_REQUEST_RESPONSE_TYPE, message)
Expand Down

0 comments on commit e0d4ecf

Please sign in to comment.